Wednesday, August 14, 2024

Additioning

 Having a moment with that ripple-adder code Medium sent me. Below, the

original which accomodates 3 positions binary nymbers. Re-did it to accomodate

4 position binaries...

                                                                        



                                                                       



*     *     *

Investigatd the compose() function. It joins two circuits together.

                                                                             


*     *     *

Creating a binary nuber:

                                                                          

               
                                                                     *     *     *

You

Qiskit; what is a register?

Copilot

In Qiskit, a quantum circuit is represented by the QuantumCircuit class1. It’s a fundamental construct for designing and simulating quantum algorithms. Let me break it down for you:
Quantum Register (Qubit Register):
A quantum register, often called a qubit register, is a collection of qubits (quantum bits).
You can think of it as a set of quantum wires, each representing a qubit.
Qiskit provides the QuantumRegister class to create and manage qubit registers2.
Example: To create a 3-qubit register, you can use:

Python
from qiskit import QuantumRegister
qreg = QuantumRegister(3)  # Creates a 3-qubit register

Classical Register (Clbit Register):
A classical register, also known as a clbit register, is a collection of classical bits.
These bits store classical information (0 or 1) and are used for measurement outcomes.
Qiskit provides the ClassicalRegister class for creating classical registers.
Example: To create a 3-bit classical register, you can use:

Python
from qiskit import ClassicalRegister
creg = ClassicalRegister(3)  # Creates a 3-bit classical register

Creating a Quantum Circuit:
To create a quantum circuit, you combine qubit and classical registers using the QuantumCircuit class.
Example:

Python
from qiskit import QuantumCircuit
qc = QuantumCircuit(qreg, creg)  # Creates a circuit with qreg and creg
Building the Circuit:
You add gates (quantum operations) to the circuit, specifying the registers or qubits they act on.
For example, you can apply a Hadamard gate to all qubits in the qreg:

Python
qc.h(qreg)  # Apply Hadamard gate to all qubits in qreg

Measurement:
Finally, you can measure the qubits and store the results in the classical register:

Python
qc.measure(qreg, creg)  # Measure qubits in qreg and store results in creg





No comments: