Skip to main content

All Questions

Filter by
Sorted by
Tagged with
1 vote
1 answer
255 views

Simple successor gate

I want to create a gate that, given a sequence of qbits that encode n, transforms that sequence in n+1, in other words the successor function. I managed to do it in qiskit by writing this: ...
ThePirate42's user avatar
0 votes
0 answers
46 views

BQSkit Selecting Starting Circuit Structure

Background On the BQSKit repository, there is a nice example of using the qfactor algorithm to instantiate a 3-qubit Toffoli circuit. For this to work, however, it is first necessary to specify an ...
Shadow43375's user avatar
2 votes
1 answer
80 views

Consecutive phased X rotation gates simplification

I have two consecutive phased X rotation (see cirq PhasedXPowGate gate definition), how to find both t' and p' angles (according to previoux cirq definition) so that two consecutive PhasedXPowGate are ...
user12910's user avatar
  • 451
2 votes
1 answer
104 views

Converting a Matrix to a Gate in OpenQasm 2

I am a beginner when it comes to quantum computing so forgive me if this is a dumb question. Does anyone know how to create a gate from any matrix on OpenQasm2? Specifically, can anyone provide any ...
Sam's user avatar
  • 31
1 vote
0 answers
180 views

PyZX optimisation steps for Clifford circuits

Given the following ZX-diagram It should represent some random Clifford circuit (LC means Local Clifford). As far as I got, any Clifford circuit can be transformed into a ZX-diagram like the above, i....
Daniele Cuomo's user avatar
4 votes
0 answers
139 views

How exactly does the QuantumCircuit.decompose() method work?

From what I can understand from the source code, the circuit is converted into a DAG before the decomposition transpiler is performed onto the DAG circuit. How does converting to a DAG circuit help us ...
sven's user avatar
  • 103
10 votes
2 answers
2k views

Transpilation into custom gate set in qiskit

In qiskit, I can transpile a given circuit into a some predefined gate set as follows (just an example) ...
Nikita Nemkov's user avatar
2 votes
1 answer
159 views

How does MCPhaseGate/MCU1Gate works internally in qiskit?

I was curious about the implementation of MCPhase/MCU1Gate and how it works without ancilla qubits. I ended up checking the code of the some auxiliary (?) function ...
123's user avatar
  • 61
1 vote
1 answer
2k views

How to code a projector operator in qiskit?

I'm new to qiskit and I want to know how do I define a projector operator in qiskit? Specifically, I have prepared a 3 qubit system, and after applying a whole lot of gates and measuring it in a state ...
thedumbkid's user avatar
2 votes
1 answer
1k views

Principal square root of Pauli Y gate in Qiskit?

I've seen a similar question asked (How do I compute the square root of the $Y$ gate?) but I'm trying to understand how I can use the gates $Y^{\frac{1}{2}}$ or $Y^{\frac{1}{4}}$ in Qiskit in terms of ...
m1cky22's user avatar
  • 131
2 votes
1 answer
801 views

Building an N-qubit Controlled S Gate

I've been beating my head against this problem for three days now and I just can't seem to crack it. To construct an N-qubit controlled Unitary gate, I can do something like this (note I'm using ...
Woody1193's user avatar
  • 351
33 votes
6 answers
15k views

How do I build a gate from a matrix on Qiskit?

I'm creating a gate for a project and need to test if it has the same results as the original circuit in a simulator, how do I build this gate on Qiskit? It's a 3 qubit gate, 8x8 matrix: $$ \frac{1}{...
Nillmer's user avatar
  • 775
3 votes
2 answers
421 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 ...
MeetR's user avatar
  • 185
6 votes
2 answers
1k views

Measuring the Hamiltonian in the VQE

I am trying to implement VQE in pyQuil and am dumbfounded by how to measure the expectation value of a general Hamiltonian on $\mathbb{C}^{2^n}$ i.e. determine $\langle\psi , H \psi\rangle$ on a ...
Jan Lukas Bosse's user avatar
13 votes
2 answers
2k 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 ...
user1271772 No more free time's user avatar
6 votes
2 answers
701 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 ...
cnada's user avatar
  • 4,774
8 votes
2 answers
692 views

Construct Controlled-$G^{\dagger}$ from known Controlled-$G$

Let there be a known a scheme (quantum circuit) of Controlled-G, where unitary gate G has G$^†$ such that G≠G$^†$ and GG$^†$=I (for example S and S$^†$, T and T$^†$, V and V$^†$, but not Pauli and H ...
John Lancaster's user avatar