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?