5

Prepare a qubit in state $|\psi\rangle=\mathrm{cos}\frac{\theta}{2}|0\rangle+\mathrm{e}^{i\phi}\mathrm{sin}\frac{\theta}{2}|1\rangle$, given the angles $\psi$ and $\theta$. Let's start with a qubit in the $|0\rangle$ state, as is customary for Q#. You can use one of the general library operations to prepare the state, such as PrepareArbitraryState. Or you ...


3

An application of the reflection operator change each amplitude of a basis state $ |i\rangle$ by $$ \alpha_i \rightarrow- \alpha_i + 2 \langle\alpha\rangle\ $$ where $ \langle\alpha\rangle\ $ is the average of all amplitudes. It follows the oracle which is use to "mark" the seeked elements $ |i\rangle$. Say for instance that you have 8 elements, so you ...


3

Q# operations are compiled into C# classes. To define a C# implementation for a Q# operation, you will need to do the following steps: Define a Q# operation with empty or intrinsic body CSharpMethod. Define a C# class that implements the abstract class into which your Q# operation gets compiled, something like public class CSharpMethod_Impl : CSharpMethod. ...


3

On hardware, the number of moments is the relevant metric. That is why cirq focuses on that. To compute circuit depth in cirq, create a new circuit using just the operations. It defaults to packing them as tightly as possible, so the number of moments will be the depth. depth = len(cirq.Circuit(my_circuit.all_operations()))


2

From what I know, no testing framework exists yet for quantum computing. I searched approximately one year ago for one and did not find anything. But this does not mean you can't test! Below are the methods I ended up using when I saw that no specialised testing framework for quantum computing was out there in the wild. Unitary simulation This method can ...


2

I take your statement that programmers "don't need to know the machinery behind the prevailing paradigm" to mean that most scientific programmers need not know how a $\mathsf{NAND}$ gate is realized, with, say, a set of $6$ or so transistors. However, probably a concept that is fundamental in quantum computing, that can be understood by anyone familiar with ...


2

Not at the moment. As of version 0.10, Q# doesn't support optional parameters, and it does not allow to define two operations with the same name that would only differ by the list of parameters (which would be a different way to do the same thing).


2

According to the openqasm spec the include statement will insert the contents of the files with the name relative to the current working directory: https://github.com/Qiskit/openqasm/blob/master/spec/qasm2.rst#language If you're using qiskit-terra as your parser this should work unless you name the local file "qelib1.inc". The parser included in the qiskit-...


1

One way that I've found that works pretty well is to define a new UDT for options, and then provide a function that returns a reasonable set of defaults. For instance, in the case you gave, you might have something like: newtype FunOptions = ( N : Int, SomeOtherOption : Double[] ); function DefaultFunOptions() : FunOptions { return (0, [0.0]); } ...


1

So Qiskit (qiskit.org) already does everything you are looking for. If you need to access the API directly then the IBMQ account connector (https://github.com/Qiskit/qiskit-ibmq-provider) is a good starting point in lieu of formal documentation.


Only top voted, non community-wiki answers of a minimum length are eligible