![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMnVmZtda9aLk59MIDSDOxVucMM7cc9G9bUOFmAhvieY2qlEsBwsVx5F0iQFQwDIEKTNAPe6wcT5fkHX0dJvHv_Jq8ZchXXP7i8Dt5IeUMXUNyYFCu78GKT3KsGZlplj0Olh6UAx9LyIQ/s400/Slicing_In_Cove.png)
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