0

I am trying to create a program in QCL (Quantum Computer Language) which randomly generates 1 of 6 states (i.e. a die rolling program). While implementing this, I found myself needing to write a function as follows:

operator CondRot(qureg r, qureg c) {
    qureg newReg = r & c;
    complex half;

    half = 1/sqrt(2);
    Matrix4x4(1, 0, 0, 0,           // <00|
              0, 1, 0, 0,           // <01|
              0, 0, half, -half,    // <10|
              0, 0, half, half,     // <11|
              newReg);
}

I was disappointed that I found myself needing to explicitly state a unitary matrix in order to accomplish my goal. I have come to the understanding that with just the Hadamard matrices and a controlled-V matrix I should be able to generate any unitary matrix I want. However, it is not immediately obvious how to do this. Do any of you know how I could rewrite this operator without explicitly stating a matrix?

Floern
  • 33,559
  • 24
  • 104
  • 119
Alex Nichol
  • 7,512
  • 4
  • 32
  • 30

1 Answers1

0

After some contemplation, I realized that I could implement what I want with complex coefficients. Here is my new implementation of CondRot:

operator CondRot(qureg r, qureg c) {
    qureg joined = r & c;
    H(r);
    V(pi / 2, joined);
    H(r);
}

Note that the result comes out to a complex matrix:

[2   0   0   0
 0   2   0   0
 0   0   1+i 1-i
 0   0   1-i 1+i] * 1/2

While this matrix contains complex values, its square is the C-Not gate. In addition, it operates on a <10| or a <11| to yield 1/sqrt(2)<10| + 1/sqrt(2)<11|.

After creating this implementation, I have come to the understanding that I do not necessarily have to produce an exact matrix in order to get the result I want. In addition, I have learned to embrace phase shift gates!

Alex Nichol
  • 7,512
  • 4
  • 32
  • 30