From 20f073f4aa1d3b8f4ca6244c3997f66613fce3b5 Mon Sep 17 00:00:00 2001 From: rawkintrevo Date: Tue, 23 Apr 2024 15:51:59 -0500 Subject: [PATCH] Closes #2210 --- docs/api.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 docs/api.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 000000000..d87b8fe00 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,69 @@ +# QuMat Class Methods + +## `__init__(self, backend_config)` +- **Purpose**: Initializes the QuMat instance with a specific backend. +- **Parameters**: + - `backend_config` (dict): Configuration for the backend including its name and options. +- **Usage**: Used to set up the quantum computing backend based on user configuration. + +## `create_empty_circuit(self, num_qubits)` +- **Purpose**: Creates an empty quantum circuit with a specified number of qubits. +- **Parameters**: + - `num_qubits` (int): Number of qubits in the quantum circuit. +- **Usage**: Used at the start of quantum computations to prepare a new quantum circuit. + +## `apply_not_gate(self, qubit_index)` +- **Purpose**: Applies a NOT gate (quantum equivalent of a classical NOT) to a specified qubit. +- **Parameters**: + - `qubit_index` (int): Index of the qubit to which the gate is applied. +- **Usage**: Used to flip the state of a qubit from 0 to 1 or from 1 to 0. + +## `apply_hadamard_gate(self, qubit_index)` +- **Purpose**: Applies a Hadamard gate to a specified qubit. +- **Parameters**: + - `qubit_index` (int): Index of the qubit. +- **Usage**: Used to create a superposition state, allowing the qubit to be both 0 and 1 simultaneously. + +## `apply_cnot_gate(self, control_qubit_index, target_qubit_index)` +- **Purpose**: Applies a Controlled-NOT (CNOT) gate between two qubits. +- **Parameters**: + - `control_qubit_index` (int): Index of the control qubit. + - `target_qubit_index` (int): Index of the target qubit. +- **Usage**: Fundamental for entangling qubits, which is essential for quantum algorithms. + +## `apply_toffoli_gate(self, control_qubit_index1, control_qubit_index2, target_qubit_index)` +- **Purpose**: Applies a Toffoli gate (CCX gate) to three qubits. +- **Parameters**: + - `control_qubit_index1` (int): Index of the first control qubit. + - `control_qubit_index2` (int): Index of the second control qubit. + - `target_qubit_index` (int): Index of the target qubit. +- **Usage**: Acts as a quantum AND gate, used in algorithms requiring conditional logic. + +## `apply_swap_gate(self, qubit_index1, qubit_index2)` +- **Purpose**: Swaps the states of two qubits. +- **Parameters**: + - `qubit_index1` (int): Index of the first qubit. + - `qubit_index2` (int): Index of the second qubit. +- **Usage**: Useful in quantum algorithms for rearranging qubit states. + +## `apply_pauli_x_gate(self, qubit_index)` +- **Purpose**: Applies a Pauli-X gate to a specified qubit. +- **Parameters**: + - `qubit_index` (int): Index of the qubit. +- **Usage**: Equivalent to a NOT gate, flips the qubit state. + +## `apply_pauli_y_gate(self, qubit_index)` +- **Purpose**: Applies a Pauli-Y gate to a specified qubit. +- **Parameters**: + - `qubit_index` (int): Index of the qubit. +- **Usage**: Impacts the phase and amplitude of a qubit’s state. + +## `apply_pauli_z_gate(self, qubit_index)` +- **Purpose**: Applies a Pauli-Z gate to a specified qubit. +- **Parameters**: + - `qubit_index` (int): Index of the qubit. +- **Usage**: Alters the phase of a qubit without changing its amplitude. + +## `execute_circuit(self)` +- **Purpose**: Executes the quantum circuit and retrieves the results. +- **Usage**: Used to run the entire set of quantum operations and measure the outcomes.