3
$\begingroup$

The R operation in Q# is listed by Microsoft in the documentation as follows

operation R (pauli : Pauli, theta : Double, qubit : Qubit) : Unit

However, when I try to use the following command in a Q# operation,

R(PauliX,0,Q1);

I get an error, referencing the line of code for the R command:

The type of the given argument does not match the expected type.

Q1 is of course a Qubit, so I don't see what could be causing the problem. I've also been having difficulty getting the R1 gate working, but I suspect for similar reasons.

To see the relevant documentation, please visit R operation, Q# Docs.

$\endgroup$

1 Answer 1

2
$\begingroup$

The second argument theta has to be a Double, and 0 is a constant of type Int. Q# doesn't have implicit type casting, so you need to make sure your second argument is a Double. If you're looking for a rotation by zero angle, you'll need to do R(PauliX, 0.0, Q1);. Alternatively, you can use ToDouble to cast an integer parameter to a Double.

$\endgroup$
1
  • $\begingroup$ This also fixes the issues I was having with other gates like R1 in case anyone viewing this is wondering. $\endgroup$
    – Alex S
    Jan 31, 2019 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.