Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [programming]

For questions relating to the process of assembling quantum programs that can be executed on a quantum computer.

3
votes
2answers
97 views

Why won't Qiskit ccx gate accept registers?

In Qiskit, they have the concept of a Toffoli gate (ccx). However, the following code throws an error: ...
7
votes
1answer
83 views

Submitting jobs to IBM devices without Python

Qiskit can be used to submit jobs to IBM devices using Python (or Swift and JavaScript). But what if I want to use a different language? For example, suppose I have a specific circuit I want to run. ...
2
votes
1answer
36 views

Plotting data in QISKit using plot_histogram

I'm trying to plot a set of data using plot_histogram, but the rendered image looks like this (the larger values are outside the image): How can I set the y-...
1
vote
1answer
34 views

TypeError: unorderable types: QuantumRegister() >= int()

I've been using qiskit for about a year now, and as of late, I've had issues finding an available backend to run my circuit on. Looking into the matter, I reinstalled qiskit to find that most ...
3
votes
1answer
53 views

How do I get a list of control qubits from Q# operations when tracing the simulation in C#?

I want to write code that prints out the controls of each operation executed during a simulation in Q#. For example this code prints the control counts: ...
5
votes
1answer
109 views

Status of software packages for quantum compiling

By "quantum compiling", what I mean is classical algorithms to solve the following problem: given a $SU(D)$ matrix $U$ (the goal) and a set of $SU(D)$ unitary matrices $V_1 \cdots V_N$ (the gates), ...
3
votes
1answer
29 views

cirq.ControlledGate from sub-circuit generator

In Cirq, is it possible to take a sub-circuit generator and use it as the sub_gate in a cirq.ControlledGate? ...
3
votes
1answer
56 views

Can I remove gates from a QuantumCircuit?

Suppose I want to implement run several circuits one after another, but they are constructed in a similar fashion. I could reinstantiate a QuantumCircuit for each ...
4
votes
1answer
30 views

How can noise on a device be simulated using measured noise parameters?

The real devices used as backends for Qiskit have calibration data that quantifies errors ($T_1$ and $T_2$, gate fidelities, etc). This can be accessed by, for example ...
2
votes
1answer
31 views

Result of a job for a list of circuits on QISKit

Suppose Circuits= [circuit1, circuit2, ..., circuitn] is a list of defined circuits. Then, ...
3
votes
1answer
80 views

Representing a real valued vector with qubits

I have some understanding that with qubits, I can represent a $2^n$ size vector using only $n$ qubits. However, I'm having trouble putting this together in a way that can make a useful circuit. Say I ...
4
votes
2answers
86 views

Does Q# have a bigint type?

Shor's algorithm works with very large integers; larger than 64 bits. So the built-in 64-bit Int type is insufficient for doing the classical processing (e.g. ...
2
votes
1answer
42 views

How do I multiply an integer and a double in Q#?

If I write this: function f(n: Int) : Double { return 1.5*n; } I get an error: ...
3
votes
1answer
45 views

How do I name the adjoint of an operation in Q#?

For example, if I've defined the operation PlusEqual, I'd like to say operation MinusEqual = Adjoint PlusEqual; but this ...
4
votes
1answer
113 views

How do I write functions that modify operations in Q#?

In Q#'s type documentation, it is mentioned that you can create signatures like this: ...
2
votes
1answer
46 views

Programmatic access to wavefunction in Q# for tests

I'm trying to write unit tests for some small Q# operations. It would be ideal if I could access the wavefunction. Is there a way to get it? I found ...
4
votes
2answers
68 views

How do I produce circuit diagrams from a Q# program?

If I implement an adder operation in Q#, I'd like to see a quantum circuit diagram of what that adder is doing in order to check that it looks right. Is there a built-in way to do this?
5
votes
1answer
132 views

How many logical qubits are needed to run Shor's algorithm efficiently on large integers ($n > 2^{1024}$)?

First, I know there are differences in logical qubits and physical qubits. It takes more physical qubits for each logical qubit due to quantum error. Wikipedia states that it takes quantum gates of ...
3
votes
1answer
34 views

Programming quantum half adder

While computing the carry bit [C=0 XOR (AB)] I am unable to compute that AB in Qiskit. I don't whether Toffoli gate is available in Qiskit. So does anyone know how to perform AB, which is basically ...
1
vote
0answers
41 views

Qiskit - Authorization Required error

When I use Qiskit to do quantum computing, I suffer from a big problem. When running the code,it turns out to be: ...
3
votes
1answer
48 views

Qiskit - expand and/or merge registers

Suppose one of my functions create some ancillary qubits and reset them. Then, another function wants to create a larger number of ancillary qubits. So, I'd like to reuse the first set of qubits and ...
6
votes
3answers
86 views

Measuring qubits in QuTiP

How can you measure qubits in QuTiP? As far as I have seen you can define a Hamiltonian and let it evolve in time. It is also possible to define a quantum circuit, however, measuring and running it ...
1
vote
1answer
50 views

ModuleNotFoundError: No module named qiskit.providers

The following message I got by running the qft.py code Traceback (most recent call last): File "qft.py", line 18, in ...
1
vote
1answer
53 views

Module BasicAer not found

After installing qiskit-terra via git (pip install qiskit), all python programs involving the line ...
2
votes
1answer
50 views

Print circuit compiled on hardware?

I would like to see the compiled circuit as executed on a hardware. Nominally, this sequence of commands should return the QASM circuit in the variable ran_qc, but ...
3
votes
2answers
78 views

How to fix? 'E1101:Instance of 'QuantumCircuit' has no 'h' member' and 'E1101:Instance of 'QuantumCircuit' has no 'cx' member'

I'm using this simple code to test my Qiskit and learn how to use it but it keeps giving this problems, how do I fix it (Using VS Code and Anaconda Python 3.7) ...
2
votes
1answer
63 views

qiskit - Is there any way to discard the results of a measurement?

I have a circuit composed by n qubits, plus a single one which is an ancilla. I'm making multiple measurements on the ancilla at different stages of the circuit, ...
2
votes
1answer
211 views

Is it possible to expand/merge different circuits?

Suppose I have created a circuit composed of some registers with the usual qc = QuantumCircuit(qr, cr) where qr and ...
3
votes
1answer
48 views

How to set up Qconfig.py and where is the file?

How to set up Qconfig.py and where is the file? I mean under which folder? Like /anaconda/lib/python3.6/site-packages/qiskit/.
3
votes
2answers
80 views

Implementing gate with two parameters using Qiskit in Python

I am trying to implement the HHL algorithm (for solving $Ax=b$). I am assuming $A$ to be unitary and Hermitian so that I can find the Hamiltonian simulation for it easily. For any $A$ to be Hermitian ...
2
votes
1answer
88 views

An algorithm with the Hadamard operator

My goal in writing this algorithm in Q# was that func would either output (1,2) or (10,20), ...
1
vote
2answers
72 views

Is it possible to create controlled gates with an exponent in Cirq?

Is it possible to create controlled gates with an exponent in Cirq? For example, a controlled $\sqrt Z$ gate.
3
votes
1answer
82 views

Quantum counting in Q#

I cannot seem to get an estimate for the number of solutions using the quantum counting algorithm described in Nielsen and Chuang, i.e. phase estimation with the Grover iteration acting as $U$. I try ...
2
votes
2answers
66 views

Why do $n$ inputs to a ket give a vector of dimension $(2^n,1)$?

NB - notation from Octave. I understand that ket([0]) is the $(1,0)$ in a $(x,y)$ plane. But when I try a ket with three numbers I get a column vector of dimension $(8,1)$. I assume that comes ...
2
votes
1answer
80 views

Are there any test examples of Octave and Quantum Entanglement?

I read this research paper. I have octave and the package running. This is an example of what I did so far - octave:3> s1 = state(normalize(ket([1,0])+ket([0,1]))) s1 = 0.00000 0.00000 0....
7
votes
0answers
71 views

Is it better to use fewer gates or fewer working qubits? [closed]

I have a script that takes a while to simulate. I can modify it in such a way where I can use fewer qubits at a time, but it will require more iterations of manipulation. I believe this will cut down ...
1
vote
0answers
19 views

How to compute the tensor product in QCL?

When I look at QCL (the documentation of the language begins in chapter 3) I don't see a way to compute the tensor product between two q-bits. Is the programming operator ...
2
votes
1answer
84 views

How to make “random U3” in QASM?

I want to make an operator: $\mathrm{U3}(\arccos(\sqrt p),0,0)$, when $p$ is a random value between $0$ and $1$ How do I write code in QASM language of this "random $\mathrm{U3}$" operator?
2
votes
2answers
331 views

How do I construct a Density Matrix corresponding to a Hamiltonian?

I have a Hamiltonian and I want to know the corresponding density matrix. The matrix I'm interested in is the one in this question.
5
votes
1answer
62 views

Flying qubits compared with stationary qubits

In a previous question I asked how stationary bits could be processed by logic gates. I casually mentioned that I could visualize qubits traversing stationary logic gates, and @DaftWullie said “It ...
3
votes
1answer
67 views

How can I resolve the error QISkit Error: The same provider has already been registered!

I am writing a small algorithm to multiply two numbers using IBM's QISkit. The code is below: times_shell.py ...
3
votes
2answers
72 views

Where is the problem stored in a quantum computer?

I am trying to develop a more intuitive understanding of quantum computing -- I suppose Feynman would tell me that’s impossible! Let’s try: if we are trying to find the minimum of a surface or ...
3
votes
1answer
81 views

Confusion over tensor products in sympy.physics.quantum.qubit (in Python)

I am working with sympy.physics.quantum.qubit to help teach myself more about quantum computing. I'm confused about how best to simplify two ket expressions that ...
1
vote
1answer
121 views

How to add two integers in Q#?

I have programmed in C++, but I am interested in writing quantum programs. I have some experience with Microsoft's Q#, and I know about the canonical Shor's and Grover's algorithms. Can anyone tell ...
11
votes
3answers
215 views

Which programming language is suitable for a beginner?

I understand there are a lot of programming languages (e.g Q#, Qiskit, etc.) Which one is suitable for someone that just started learning programming and don't know anything about quantum mechanics?
4
votes
2answers
69 views

How does one obtain amplitude information in Q#?

Is it possible to obtain amplitude information (in lexicographic ordering) for a particular qubit register in Q#? For example, in the following code: ...
10
votes
2answers
284 views

Automatic compilation of quantum circuits

A recent question here asked how to compile the 4-qubit gate CCCZ (controlled-controlled-controlled-Z) into simple 1-qubit and 2-qubit gates, and the only answer given so far requires 63 gates! The ...
4
votes
2answers
147 views

How do we code the matrix for a controlled operation knowing the control qubit, the target qubit and the $2\times 2$ unitary?

Having n qubits, I want to have the unitary described a controlled operation. Say for example you get as input a unitary, an index for a controlled qubit and another for a target. How would you code ...
7
votes
2answers
367 views

Possibility of a “reset” quantum gate

I wish to have a "reset" gate. This gate would have an effect to bring a qubit to the $\mid0\rangle$ state. Clearly, such a gate is not unitary (and so I'm unable to find any reliable implementation ...
5
votes
1answer
323 views

List of qubit locations with cirq

As far I understand, qubits in cirq are labelled by their positions on chip. For example print( cirq.google.Foxtail.qubits ) yields ...