I am looking at the homepage of Qrisp, and they have an example of how to multiply two registers with Qiskit:
from qiskit import (QuantumCircuit, QuantumRegister,
ClassicalRegister, Aer, execute)
from qiskit.circuit.library import RGQFTMultiplier
n = 6
a = QuantumRegister(n)
b = QuantumRegister(n)
res = QuantumRegister(2*n)
cl_res = ClassicalRegister(2*n)
qc = QuantumCircuit(a, b, res, cl_res)
for i in range(len(a)):
if 3 & 1<<i: qc.x(a[i])
for i in range(len(b)):
if 4 & 1<<i: qc.x(b[i])
qc.append(RGQFTMultiplier(n, 2*n),
list(a) + list(b) + list(res))
qc.measure(res, cl_res)
backend = Aer.get_backend('qasm_simulator')
counts_dic = execute(qc, backend).result().get_counts()
print({int(k, 2) : v for k, v in counts_dic.items()})
#Yields: {12: 1024}
However, this no longer works in Qiskit 1.0.
I tried moving the Aer backend to from qiskit_aer import AerSimulator
as mentioned here: Docs, and got this code:
from qiskit import (QuantumCircuit, QuantumRegister,
ClassicalRegister, transpile)
from qiskit.circuit.library import RGQFTMultiplier
from qiskit_aer import AerSimulator
n = 6
a = QuantumRegister(n)
b = QuantumRegister(n)
res = QuantumRegister(2*n)
cl_res = ClassicalRegister(2*n)
qc = QuantumCircuit(a, b, res, cl_res)
for i in range(len(a)):
if 3 & 1<<i: qc.x(a[i])
for i in range(len(b)):
if 4 & 1<<i: qc.x(b[i])
qc.append(RGQFTMultiplier(n, 2*n),
list(a) + list(b) + list(res))
qc.measure(res, cl_res)
backend = AerSimulator()
# backend = AerSimulator.get_backend('qasm_simulator')
# new_circuit = transpile(qc, backend)
job = backend.run([qc], shots=1024)
print(job.result())
counts_dic = job.result().get_counts()
print({int(k, 2) : v for k, v in counts_dic.items()})
#Yields: {12: 1024}
But now I get this error:
AerError: 'unknown instruction: RGQFTMultiplier'
So I am looking for an actual working implementation of a Qiskit multiplier to multiply 3 and 4.