qiskit-documentation/docs/api/qiskit/0.41/qiskit.algorithms.linear_so...

3890 lines
188 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: NumPyMatrix
description: API reference for qiskit.algorithms.linear_solvers.NumPyMatrix
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.algorithms.linear_solvers.NumPyMatrix
---
# NumPyMatrix
<Class id="qiskit.algorithms.linear_solvers.NumPyMatrix" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.23/qiskit/algorithms/linear_solvers/matrices/numpy_matrix.py" signature="NumPyMatrix(matrix, tolerance=0.01, evolution_time=1.0, name='np_matrix')" modifiers="class">
Bases: [`qiskit.algorithms.linear_solvers.matrices.linear_system_matrix.LinearSystemMatrix`](qiskit.algorithms.linear_solvers.LinearSystemMatrix "qiskit.algorithms.linear_solvers.matrices.linear_system_matrix.LinearSystemMatrix")
The deprecated class of matrices given as a numpy array.
Examples:
```python
import warnings
import numpy as np
from qiskit import QuantumCircuit
from qiskit.algorithms.linear_solvers.matrices.numpy_matrix import NumPyMatrix
with warnings.catch_warnings():
warnings.simplefilter('ignore')
matrix = NumPyMatrix(np.array([[1 / 2, 1 / 6, 0, 0], [1 / 6, 1 / 2, 1 / 6, 0],
[0, 1 / 6, 1 / 2, 1 / 6], [0, 0, 1 / 6, 1 / 2]]))
power = 2
num_qubits = matrix.num_state_qubits
# Controlled power (as used within QPE)
pow_circ = matrix.power(power).control()
circ_qubits = pow_circ.num_qubits
qc = QuantumCircuit(circ_qubits)
qc.append(matrix.power(power).control(), list(range(circ_qubits)))
```
**Parameters**
* **matrix** (`ndarray`) The matrix defining the linear system problem.
* **tolerance** (`float`) The accuracy desired for the approximation.
* **evolution\_time** (`float`) The time of the Hamiltonian simulation.
* **name** (`str`) The name of the object.
## Methods
### add\_bits
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.add_bits" signature="NumPyMatrix.add_bits(bits)">
Add Bits to the circuit.
**Return type**
`None`
</Function>
### add\_calibration
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.add_calibration" signature="NumPyMatrix.add_calibration(gate, qubits, schedule, params=None)">
Register a low-level, custom pulse definition for the given gate.
**Parameters**
* **gate** (*Union\[*[*Gate*](qiskit.circuit.Gate "qiskit.circuit.Gate")*, str]*) Gate information.
* **qubits** (*Union\[int, Tuple\[int]]*) List of qubits to be measured.
* **schedule** ([*Schedule*](qiskit.pulse.Schedule "qiskit.pulse.Schedule")) Schedule information.
* **params** (*Optional\[List\[Union\[float,* [*Parameter*](qiskit.circuit.Parameter "qiskit.circuit.Parameter")*]]]*) A list of parameters.
**Raises**
**Exception** if the gate is of type string and params is None.
**Return type**
`None`
</Function>
### add\_register
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.add_register" signature="NumPyMatrix.add_register(*regs)">
Add registers.
**Return type**
`None`
</Function>
### append
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.append" signature="NumPyMatrix.append(instruction, qargs=None, cargs=None)">
Append one or more instructions to the end of the circuit, modifying the circuit in place.
The `qargs` and `cargs` will be expanded and broadcast according to the rules of the given [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction"), and any non-`Bit` specifiers (such as integer indices) will be resolved into the relevant instances.
If a [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction") is given, it will be unwrapped, verified in the context of this circuit, and a new object will be appended to the circuit. In this case, you may not pass `qargs` or `cargs` separately.
**Parameters**
* **instruction** [`Instruction`](qiskit.circuit.Instruction "qiskit.circuit.Instruction") instance to append, or a [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction") with all its context.
* **qargs** specifiers of the [`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.Qubit")s to attach instruction to.
* **cargs** specifiers of the [`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.Clbit")s to attach instruction to.
**Returns**
a handle to the [`CircuitInstruction`](qiskit.circuit.CircuitInstruction "qiskit.circuit.CircuitInstruction")s that were actually added to the circuit.
**Return type**
[qiskit.circuit.InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
**Raises**
**CircuitError** if the operation passed is not an instance of `Instruction`.
</Function>
### assign\_parameters
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.assign_parameters" signature="NumPyMatrix.assign_parameters(parameters, inplace=False)">
Assign parameters to new parameters or values.
If `parameters` is passed as a dictionary, the keys must be [`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.Parameter") instances in the current circuit. The values of the dictionary can either be numeric values or new parameter objects.
If `parameters` is passed as a list or array, the elements are assigned to the current parameters in the order of [`parameters`](qiskit.algorithms.linear_solvers.NumPyMatrix#parameters "qiskit.algorithms.linear_solvers.NumPyMatrix.parameters") which is sorted alphabetically (while respecting the ordering in [`ParameterVector`](qiskit.circuit.ParameterVector "qiskit.circuit.ParameterVector") objects).
The values can be assigned to the current circuit object or to a copy of it.
**Parameters**
* **parameters** (`Union`\[`Mapping`\[[`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.parameter.Parameter"), `Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]], `Sequence`\[`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]]]) Either a dictionary or iterable specifying the new parameter values.
* **inplace** (`bool`) If False, a copy of the circuit with the bound parameters is returned. If True the circuit instance itself is modified.
**Raises**
* **CircuitError** If parameters is a dict and contains parameters not present in the circuit.
* **ValueError** If parameters is a list/array and the length mismatches the number of free parameters in the circuit.
**Return type**
`Optional`\[QuantumCircuit]
**Returns**
A copy of the circuit with bound parameters, if `inplace` is False, otherwise None.
**Examples**
Create a parameterized circuit and assign the parameters in-place.
```python
from qiskit.circuit import QuantumCircuit, Parameter
circuit = QuantumCircuit(2)
params = [Parameter('A'), Parameter('B'), Parameter('C')]
circuit.ry(params[0], 0)
circuit.crx(params[1], 0, 1)
circuit.draw('mpl')
circuit.assign_parameters({params[0]: params[2]}, inplace=True)
circuit.draw('mpl')
```
![../\_images/qiskit-algorithms-linear\_solvers-NumPyMatrix-assign\_parameters-1\_00.png](/images/api/qiskit/0.41/qiskit-algorithms-linear_solvers-NumPyMatrix-assign_parameters-1_00.png)
![../\_images/qiskit-algorithms-linear\_solvers-NumPyMatrix-assign\_parameters-1\_01.png](/images/api/qiskit/0.41/qiskit-algorithms-linear_solvers-NumPyMatrix-assign_parameters-1_01.png)
Bind the values out-of-place by list and get a copy of the original circuit.
```python
from qiskit.circuit import QuantumCircuit, ParameterVector
circuit = QuantumCircuit(2)
params = ParameterVector('P', 2)
circuit.ry(params[0], 0)
circuit.crx(params[1], 0, 1)
bound_circuit = circuit.assign_parameters([1, 2])
bound_circuit.draw('mpl')
circuit.draw('mpl')
```
![../\_images/qiskit-algorithms-linear\_solvers-NumPyMatrix-assign\_parameters-2\_00.png](/images/api/qiskit/0.41/qiskit-algorithms-linear_solvers-NumPyMatrix-assign_parameters-2_00.png)
![../\_images/qiskit-algorithms-linear\_solvers-NumPyMatrix-assign\_parameters-2\_01.png](/images/api/qiskit/0.41/qiskit-algorithms-linear_solvers-NumPyMatrix-assign_parameters-2_01.png)
</Function>
### barrier
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.barrier" signature="NumPyMatrix.barrier(*qargs, label=None)">
Apply `Barrier`. If qargs is empty, applies to all qubits in the circuit.
**Parameters**
* **qargs** (*QubitSpecifier*) Specification for one or more qubit arguments.
* **label** (*str*) The string label of the barrier.
**Returns**
handle to the added instructions.
**Return type**
[qiskit.circuit.InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
</Function>
### bind\_parameters
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.bind_parameters" signature="NumPyMatrix.bind_parameters(values)">
Assign numeric parameters to values yielding a new circuit.
If the values are given as list or array they are bound to the circuit in the order of [`parameters`](qiskit.algorithms.linear_solvers.NumPyMatrix#parameters "qiskit.algorithms.linear_solvers.NumPyMatrix.parameters") (see the docstring for more details).
To assign new Parameter objects or bind the values in-place, without yielding a new circuit, use the [`assign_parameters()`](qiskit.algorithms.linear_solvers.NumPyMatrix#assign_parameters "qiskit.algorithms.linear_solvers.NumPyMatrix.assign_parameters") method.
**Parameters**
**values** (`Union`\[`Mapping`\[[`Parameter`](qiskit.circuit.Parameter "qiskit.circuit.parameter.Parameter"), `float`], `Sequence`\[`float`]]) `{parameter: value, ...}` or `[value1, value2, ...]`
**Raises**
* **CircuitError** If values is a dict and contains parameters not present in the circuit.
* **TypeError** If values contains a ParameterExpression.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Returns**
Copy of self with assignment substitution.
</Function>
### break\_loop
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.break_loop" signature="NumPyMatrix.break_loop()">
Apply `BreakLoopOp`.
<Admonition title="Warning" type="caution">
If you are using the context-manager “builder” forms of [`if_test()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_test "qiskit.algorithms.linear_solvers.NumPyMatrix.if_test"), [`for_loop()`](qiskit.algorithms.linear_solvers.NumPyMatrix#for_loop "qiskit.algorithms.linear_solvers.NumPyMatrix.for_loop") or [`while_loop()`](qiskit.algorithms.linear_solvers.NumPyMatrix#while_loop "qiskit.algorithms.linear_solvers.NumPyMatrix.while_loop"), you can only call this method if you are within a loop context, because otherwise the “resource width” of the operation cannot be determined. This would quickly lead to invalid circuits, and so if you are trying to construct a reusable loop body (without the context managers), you must also use the non-context-manager form of [`if_test()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_test "qiskit.algorithms.linear_solvers.NumPyMatrix.if_test") and [`if_else()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_else "qiskit.algorithms.linear_solvers.NumPyMatrix.if_else"). Take care that the [`BreakLoopOp`](qiskit.circuit.BreakLoopOp "qiskit.circuit.BreakLoopOp") instruction must span all the resources of its containing loop, not just the immediate scope.
</Admonition>
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instruction created.
**Raises**
**CircuitError** if this method was called within a builder context, but not contained within a loop.
</Function>
### cast
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cast" signature="NumPyMatrix.cast(value, type_)" modifiers="static">
Best effort to cast value to type. Otherwise, returns the value.
**Return type**
`Union`\[`TypeVar`(`S`), `TypeVar`(`T`)]
</Function>
### cbit\_argument\_conversion
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cbit_argument_conversion" signature="NumPyMatrix.cbit_argument_conversion(clbit_representation)">
Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.
**Parameters**
**clbit\_representation** (*Object*) representation to expand
**Returns**
Where each tuple is a classical bit.
**Return type**
List(tuple)
</Function>
### ccx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ccx" signature="NumPyMatrix.ccx(control_qubit1, control_qubit2, target_qubit, ctrl_state=None)">
Apply [`CCXGate`](qiskit.circuit.library.CCXGate "qiskit.circuit.library.CCXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the first control.
* **control\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the second control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### ccz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ccz" signature="NumPyMatrix.ccz(control_qubit1, control_qubit2, target_qubit, label=None, ctrl_state=None)">
Apply `CCZGate`.
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the first control.
* **control\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the second control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 10). Defaults to controlling on the 11 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### ch
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ch" signature="NumPyMatrix.ch(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CHGate`](qiskit.circuit.library.CHGate "qiskit.circuit.library.CHGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### clear
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.clear" signature="NumPyMatrix.clear()">
Clear all instructions in self.
Clearing the circuits will keep the metadata and calibrations.
**Return type**
`None`
</Function>
### cls\_instances
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cls_instances" signature="NumPyMatrix.cls_instances()" modifiers="classmethod">
Return the current number of instances of this class, useful for auto naming.
**Return type**
`int`
</Function>
### cls\_prefix
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cls_prefix" signature="NumPyMatrix.cls_prefix()" modifiers="classmethod">
Return the prefix to use for auto naming.
**Return type**
`str`
</Function>
### cnot
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cnot" signature="NumPyMatrix.cnot(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CXGate`](qiskit.circuit.library.CXGate "qiskit.circuit.library.CXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
<Admonition title="See also" type="note">
QuantumCircuit.cx: the same function with a different name.
</Admonition>
</Function>
### compose
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.compose" signature="NumPyMatrix.compose(other, qubits=None, clbits=None, front=False, inplace=False, wrap=False)">
Compose circuit with `other` circuit or instruction, optionally permuting wires.
`other` can be narrower or of equal width to `self`.
**Parameters**
* **other** ([*qiskit.circuit.Instruction*](qiskit.circuit.Instruction "qiskit.circuit.Instruction") *or*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) (sub)circuit or instruction to compose onto self. If not a [`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit"), this can be anything that [`append`](qiskit.algorithms.linear_solvers.NumPyMatrix#append "qiskit.algorithms.linear_solvers.NumPyMatrix.append") will accept.
* **qubits** (*list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*|int]*) qubits of self to compose onto.
* **clbits** (*list\[*[*Clbit*](qiskit.circuit.Clbit "qiskit.circuit.Clbit")*|int]*) clbits of self to compose onto.
* **front** (*bool*) If True, front composition will be performed. This is not possible within control-flow builder context managers.
* **inplace** (*bool*) If True, modify the object. Otherwise return composed circuit.
* **wrap** (*bool*) If True, wraps the other circuit into a gate (or instruction, depending on whether it contains only unitary instructions) before composing it onto self.
**Returns**
the composed circuit (returns None if inplace==True).
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
* **CircuitError** if no correct wire mapping can be made between the two circuits, such as if `other` is wider than `self`.
* **CircuitError** if trying to emit a new circuit while `self` has a partially built control-flow context active, such as the context-manager forms of [`if_test()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_test "qiskit.algorithms.linear_solvers.NumPyMatrix.if_test"), [`for_loop()`](qiskit.algorithms.linear_solvers.NumPyMatrix#for_loop "qiskit.algorithms.linear_solvers.NumPyMatrix.for_loop") and [`while_loop()`](qiskit.algorithms.linear_solvers.NumPyMatrix#while_loop "qiskit.algorithms.linear_solvers.NumPyMatrix.while_loop").
* **CircuitError** if trying to compose to the front of a circuit when a control-flow builder block is active; there is no clear meaning to this action.
**Examples**
```python
>>> lhs.compose(rhs, qubits=[3, 2], inplace=True)
```
```python
┌───┐ ┌─────┐ ┌───┐
lqr_1_0: ───┤ H ├─── rqr_0: ──■──┤ Tdg ├ lqr_1_0: ───┤ H ├───────────────
├───┤ ┌─┴─┐└─────┘ ├───┤
lqr_1_1: ───┤ X ├─── rqr_1: ┤ X ├─────── lqr_1_1: ───┤ X ├───────────────
┌──┴───┴──┐ └───┘ ┌──┴───┴──┐┌───┐
lqr_1_2: ┤ U1(0.1) ├ + = lqr_1_2: ┤ U1(0.1) ├┤ X ├───────
└─────────┘ └─────────┘└─┬─┘┌─────┐
lqr_2_0: ─────■───── lqr_2_0: ─────■───────■──┤ Tdg ├
┌─┴─┐ ┌─┴─┐ └─────┘
lqr_2_1: ───┤ X ├─── lqr_2_1: ───┤ X ├───────────────
└───┘ └───┘
lcr_0: 0 ═══════════ lcr_0: 0 ═══════════════════════
lcr_1: 0 ═══════════ lcr_1: 0 ═══════════════════════
```
</Function>
### condition\_bounds
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.condition_bounds" signature="NumPyMatrix.condition_bounds()">
Return lower and upper bounds on the condition number of the matrix.
**Return type**
`Tuple`\[`float`, `float`]
</Function>
### continue\_loop
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.continue_loop" signature="NumPyMatrix.continue_loop()">
Apply `ContinueLoopOp`.
<Admonition title="Warning" type="caution">
If you are using the context-manager “builder” forms of [`if_test()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_test "qiskit.algorithms.linear_solvers.NumPyMatrix.if_test"), [`for_loop()`](qiskit.algorithms.linear_solvers.NumPyMatrix#for_loop "qiskit.algorithms.linear_solvers.NumPyMatrix.for_loop") or [`while_loop()`](qiskit.algorithms.linear_solvers.NumPyMatrix#while_loop "qiskit.algorithms.linear_solvers.NumPyMatrix.while_loop"), you can only call this method if you are within a loop context, because otherwise the “resource width” of the operation cannot be determined. This would quickly lead to invalid circuits, and so if you are trying to construct a reusable loop body (without the context managers), you must also use the non-context-manager form of [`if_test()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_test "qiskit.algorithms.linear_solvers.NumPyMatrix.if_test") and [`if_else()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_else "qiskit.algorithms.linear_solvers.NumPyMatrix.if_else"). Take care that the [`ContinueLoopOp`](qiskit.circuit.ContinueLoopOp "qiskit.circuit.ContinueLoopOp") instruction must span all the resources of its containing loop, not just the immediate scope.
</Admonition>
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instruction created.
**Raises**
**CircuitError** if this method was called within a builder context, but not contained within a loop.
</Function>
### control
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.control" signature="NumPyMatrix.control(num_ctrl_qubits=1, label=None, ctrl_state=None)">
Control this circuit on `num_ctrl_qubits` qubits.
**Parameters**
* **num\_ctrl\_qubits** (*int*) The number of control qubits.
* **label** (*str*) An optional label to give the controlled operation for visualization.
* **ctrl\_state** (*str or int*) The control state in decimal or as a bitstring (e.g. 111). If None, use `2**num_ctrl_qubits - 1`.
**Returns**
The controlled version of this circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**CircuitError** If the circuit contains a non-unitary operation and cannot be controlled.
</Function>
### copy
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.copy" signature="NumPyMatrix.copy(name=None)">
Copy the circuit.
**Parameters**
**name** (*str*) name to be given to the copied circuit. If None, then the name stays the same
**Returns**
a deepcopy of the current circuit, with the specified name
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### copy\_empty\_like
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.copy_empty_like" signature="NumPyMatrix.copy_empty_like(name=None)">
Return a copy of self with the same structure but empty.
#### That structure includes:
* name, calibrations and other metadata
* global phase
* all the qubits and clbits, including the registers
**Parameters**
**name** (*str*) Name for the copied circuit. If None, then the name stays the same.
**Returns**
An empty copy of self.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### count\_ops
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.count_ops" signature="NumPyMatrix.count_ops()">
Count each operation kind in the circuit.
**Returns**
a breakdown of how many operations of each kind, sorted by amount.
**Return type**
OrderedDict
</Function>
### cp
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cp" signature="NumPyMatrix.cp(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CPhaseGate`](qiskit.circuit.library.CPhaseGate "qiskit.circuit.library.CPhaseGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### crx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.crx" signature="NumPyMatrix.crx(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CRXGate`](qiskit.circuit.library.CRXGate "qiskit.circuit.library.CRXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cry
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cry" signature="NumPyMatrix.cry(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CRYGate`](qiskit.circuit.library.CRYGate "qiskit.circuit.library.CRYGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### crz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.crz" signature="NumPyMatrix.crz(theta, control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CRZGate`](qiskit.circuit.library.CRZGate "qiskit.circuit.library.CRZGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cs
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cs" signature="NumPyMatrix.cs(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply `CSGate`.
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### csdg
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.csdg" signature="NumPyMatrix.csdg(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply `CSdgGate`.
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cswap
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cswap" signature="NumPyMatrix.cswap(control_qubit, target_qubit1, target_qubit2, label=None, ctrl_state=None)">
Apply [`CSwapGate`](qiskit.circuit.library.CSwapGate "qiskit.circuit.library.CSwapGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **target\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### csx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.csx" signature="NumPyMatrix.csx(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CSXGate`](qiskit.circuit.library.CSXGate "qiskit.circuit.library.CSXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cu
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cu" signature="NumPyMatrix.cu(theta, phi, lam, gamma, control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CUGate`](qiskit.circuit.library.CUGate "qiskit.circuit.library.CUGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The $\theta$ rotation angle of the gate.
* **phi** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The $\phi$ rotation angle of the gate.
* **lam** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The $\lambda$ rotation angle of the gate.
* **gamma** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The global phase applied of the U gate, if applied.
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cx" signature="NumPyMatrix.cx(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CXGate`](qiskit.circuit.library.CXGate "qiskit.circuit.library.CXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cy
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cy" signature="NumPyMatrix.cy(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CYGate`](qiskit.circuit.library.CYGate "qiskit.circuit.library.CYGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the controls.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### cz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.cz" signature="NumPyMatrix.cz(control_qubit, target_qubit, label=None, ctrl_state=None)">
Apply [`CZGate`](qiskit.circuit.library.CZGate "qiskit.circuit.library.CZGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the controls.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
* **ctrl\_state** (`Union`\[`str`, `int`, `None`]) The control state in decimal, or as a bitstring (e.g. 1). Defaults to controlling on the 1 state.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### dcx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.dcx" signature="NumPyMatrix.dcx(qubit1, qubit2)">
Apply [`DCXGate`](qiskit.circuit.library.DCXGate "qiskit.circuit.library.DCXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### decompose
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.decompose" signature="NumPyMatrix.decompose(gates_to_decompose=None, reps=1)">
Call a decomposition pass on this circuit, to decompose one level (shallow decompose).
**Parameters**
* **gates\_to\_decompose** (*str or list(str)*) optional subset of gates to decompose. Defaults to all gates in circuit.
* **reps** (*int*) Optional number of times the circuit should be decomposed. For instance, `reps=2` equals calling `circuit.decompose().decompose()`. can decompose specific gates specific time
**Returns**
a circuit one level decomposed
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### delay
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.delay" signature="NumPyMatrix.delay(duration, qarg=None, unit='dt')">
Apply [`Delay`](qiskit.circuit.Delay "qiskit.circuit.Delay"). If qarg is None, applies to all qubits. When applying to multiple qubits, delays with the same duration will be created.
**Parameters**
* **duration** (*int or float or* [*ParameterExpression*](qiskit.circuit.ParameterExpression "qiskit.circuit.ParameterExpression")) duration of the delay.
* **qarg** (*Object*) qubit argument to apply this delay.
* **unit** (*str*) unit of the duration. Supported units: s, ms, us, ns, ps, dt. Default is `dt`, i.e. integer time unit depending on the target backend.
**Returns**
handle to the added instructions.
**Return type**
[qiskit.circuit.InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
**Raises**
**CircuitError** if arguments have bad format.
</Function>
### depth
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.depth" signature="NumPyMatrix.depth(*args, **kwargs)">
Return circuit depth (i.e., length of critical path).
**Parameters**
**filter\_function** (*callable*) A function to filter instructions. Should take as input a tuple of (Instruction, list(Qubit), list(Clbit)). Instructions for which the function returns False are ignored in the computation of the circuit depth. By default filters out “directives”, such as barrier or snapshot.
**Returns**
Depth of circuit.
**Return type**
int
**Notes**
The circuit depth and the DAG depth need not be the same.
</Function>
### diagonal
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.diagonal" signature="NumPyMatrix.diagonal(diag, qubit)">
Attach a diagonal gate to a circuit.
The decomposition is based on Theorem 7 given in “Synthesis of Quantum Logic Circuits” by Shende et al. ([https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf)).
**Parameters**
* **diag** (*list*) list of the 2^k diagonal entries (for a diagonal gate on k qubits). Must contain at least two entries
* **qubit** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list*) list of k qubits the diagonal is acting on (the order of the qubits specifies the computational basis in which the diagonal gate is provided: the first element in diag acts on the state where all the qubits in q are in the state 0, the second entry acts on the state where all the qubits q\[1],…,q\[k-1] are in the state zero and q\[0] is in the state 1, and so on)
**Returns**
the diagonal gate which was attached to the circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the list of the diagonal entries or the qubit list is in bad format; if the number of diagonal entries is not 2^k, where k denotes the number of qubits
</Function>
### draw
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.draw" signature="NumPyMatrix.draw(*args, **kwargs)">
Draw the quantum circuit. Use the output parameter to choose the drawing format:
**text**: ASCII art TextDrawing that can be printed in the console.
**mpl**: images with color rendered purely in Python using matplotlib.
**latex**: high-quality images compiled via latex.
**latex\_source**: raw uncompiled latex output.
**Parameters**
* **output** (*str*) select the output method to use for drawing the circuit. Valid choices are `text`, `mpl`, `latex`, `latex_source`. By default the text drawer is used unless the user config file (usually `~/.qiskit/settings.conf`) has an alternative backend set as the default. For example, `circuit_drawer = latex`. If the output kwarg is set, that backend will always be used over the default in the user config file.
* **scale** (*float*) scale of image to draw (shrink if \< 1.0). Only used by the mpl, latex and latex\_source outputs. Defaults to 1.0.
* **filename** (*str*) file path to save image to. Defaults to None.
* **style** (*dict or str*) dictionary of style or file name of style json file. This option is only used by the mpl or latex output type. If style is a str, it is used as the path to a json file which contains a style dict. The file will be opened, parsed, and then any style elements in the dict will replace the default values in the input dict. A file to be loaded must end in `.json`, but the name entered here can omit `.json`. For example, `style='iqx.json'` or `style='iqx'`. If style is a dict and the `'name'` key is set, that name will be used to load a json file, followed by loading the other items in the style dict. For example, `style={'name': 'iqx'}`. If style is not a str and name is not a key in the style dict, then the default value from the user config file (usually `~/.qiskit/settings.conf`) will be used, for example, `circuit_mpl_style = iqx`. If none of these are set, the default style will be used. The search path for style json files can be specified in the user config, for example, `circuit_mpl_style_path = /home/user/styles:/home/user`. See: [`DefaultStyle`](qiskit.visualization.qcstyle.DefaultStyle "qiskit.visualization.qcstyle.DefaultStyle") for more information on the contents.
* **interactive** (*bool*) when set to true, show the circuit in a new window (for mpl this depends on the matplotlib backend being used supporting this). Note when used with either the text or the latex\_source output type this has no effect and will be silently ignored. Defaults to False.
* **reverse\_bits** (*bool*) when set to True, reverse the bit order inside registers for the output visualization. Defaults to False unless the user config file (usually `~/.qiskit/settings.conf`) has an alternative value set. For example, `circuit_reverse_bits = True`.
* **plot\_barriers** (*bool*) enable/disable drawing barriers in the output circuit. Defaults to True.
* **justify** (*string*) options are `left`, `right` or `none`. If anything else is supplied, it defaults to left justified. It refers to where gates should be placed in the output circuit if there is an option. `none` results in each gate being placed in its own column.
* **vertical\_compression** (*string*) `high`, `medium` or `low`. It merges the lines generated by the text output so the drawing will take less vertical room. Default is `medium`. Only used by the text output, will be silently ignored otherwise.
* **idle\_wires** (*bool*) include idle wires (wires with no circuit elements) in output visualization. Default is True.
* **with\_layout** (*bool*) include layout information, with labels on the physical layout. Default is True.
* **fold** (*int*) sets pagination. It can be disabled using -1. In text, sets the length of the lines. This is useful when the drawing does not fit in the console. If None (default), it will try to guess the console width using `shutil.get_terminal_size()`. However, if running in jupyter, the default line length is set to 80 characters. In mpl, it is the number of (visual) layers before folding. Default is 25.
* **ax** (*matplotlib.axes.Axes*) Only used by the mpl backend. An optional Axes object to be used for the visualization output. If none is specified, a new matplotlib Figure will be created and used. Additionally, if specified there will be no returned Figure since it is redundant.
* **initial\_state** (*bool*) Optional. Adds `|0>` in the beginning of the wire. Default is False.
* **cregbundle** (*bool*) Optional. If set True, bundle classical registers. Default is True, except for when `output` is set to `"text"`.
* **wire\_order** (*list*) Optional. A list of integers used to reorder the display of the bits. The list must have an entry for every bit with the bits in the range 0 to (num\_qubits + num\_clbits).
**Returns**
`TextDrawing` or `matplotlib.figure` or `PIL.Image` or `str`:
* **TextDrawing (output=text)**
A drawing that can be printed as ascii art.
* **matplotlib.figure.Figure (output=mpl)**
A matplotlib figure object for the circuit diagram.
* **PIL.Image (output=latex)**
An in-memory representation of the image of the circuit diagram.
* **str (output=latex\_source)**
The LaTeX source code for visualizing the circuit diagram.
**Raises**
* [**VisualizationError**](qiskit.visualization.VisualizationError "qiskit.visualization.VisualizationError") when an invalid output method is selected
* **ImportError** when the output methods requires non-installed libraries.
**Example**
```python
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
q = QuantumRegister(1)
c = ClassicalRegister(1)
qc = QuantumCircuit(q, c)
qc.h(q)
qc.measure(q, c)
qc.draw(output='mpl', style={'backgroundcolor': '#EEEEEE'})
```
![../\_images/qiskit-algorithms-linear\_solvers-NumPyMatrix-draw-1.png](/images/api/qiskit/0.41/qiskit-algorithms-linear_solvers-NumPyMatrix-draw-1.png)
</Function>
### ecr
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ecr" signature="NumPyMatrix.ecr(qubit1, qubit2)">
Apply [`ECRGate`](qiskit.circuit.library.ECRGate "qiskit.circuit.library.ECRGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubits to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubits to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### eigs\_bounds
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.eigs_bounds" signature="NumPyMatrix.eigs_bounds()">
Return lower and upper bounds on the eigenvalues of the matrix.
**Return type**
`Tuple`\[`float`, `float`]
</Function>
### find\_bit
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.find_bit" signature="NumPyMatrix.find_bit(bit)">
Find locations in the circuit which can be used to reference a given `Bit`.
**Parameters**
**bit** (*Bit*) The bit to locate.
**Returns**
**A 2-tuple. The first element (`index`)**
contains the index at which the `Bit` can be found (in either `qubits`, `clbits`, depending on its type). The second element (`registers`) is a list of `(register, index)` pairs with an entry for each `Register` in the circuit which contains the `Bit` (and the index in the `Register` at which it can be found).
**Return type**
namedtuple(int, List\[Tuple(Register, int)])
**Notes**
The circuit index of an `AncillaQubit` will be its index in `qubits`, not `ancillas`.
**Raises**
* **CircuitError** If the supplied `Bit` was of an unknown type.
* **CircuitError** If the supplied `Bit` could not be found on the circuit.
</Function>
### for\_loop
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.for_loop" signature="NumPyMatrix.for_loop(indexset, loop_parameter=None, body=None, qubits=None, clbits=None, *, label=None)">
Create a `for` loop on this circuit.
There are two forms for calling this function. If called with all its arguments (with the possible exception of `label`), it will create a `ForLoopOp` with the given `body`. If `body` (and `qubits` and `clbits`) are *not* passed, then this acts as a context manager, which, when entered, provides a loop variable (unless one is given, in which case it will be reused) and will automatically build a `ForLoopOp` when the scope finishes. In this form, you do not need to keep track of the qubits or clbits you are using, because the scope will handle it for you.
For example:
```python
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 1)
with qc.for_loop(range(5)) as i:
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 0)
qc.break_loop().c_if(0, True)
```
**Parameters**
* **indexset** (*Iterable\[int]*) A collection of integers to loop over. Always necessary.
* **loop\_parameter** (*Optional\[*[*Parameter*](qiskit.circuit.Parameter "qiskit.circuit.Parameter")*]*)
The parameter used within `body` to which the values from `indexset` will be assigned. In the context-manager form, if this argument is not supplied, then a loop parameter will be allocated for you and returned as the value of the `with` statement. This will only be bound into the circuit if it is used within the body.
If this argument is `None` in the manual form of this method, `body` will be repeated once for each of the items in `indexset` but their values will be ignored.
* **body** (*Optional\[*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*]*) The loop body to be repeatedly executed. Omit this to use the context-manager mode.
* **qubits** (*Optional\[Sequence\[QubitSpecifier]]*) The circuit qubits over which the loop body should be run. Omit this to use the context-manager mode.
* **clbits** (*Optional\[Sequence\[ClbitSpecifier]]*) The circuit clbits over which the loop body should be run. Omit this to use the context-manager mode.
* **label** (*Optional\[str]*) The string label of the instruction in the circuit.
**Returns**
depending on the call signature, either a context manager for creating the for loop (it will automatically be added to the circuit at the end of the block), or an `InstructionSet` handle to the appended loop operation.
**Return type**
[InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet") or ForLoopContext
**Raises**
**CircuitError** if an incorrect calling convention is used.
</Function>
### fredkin
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.fredkin" signature="NumPyMatrix.fredkin(control_qubit, target_qubit1, target_qubit2)">
Apply [`CSwapGate`](qiskit.circuit.library.CSwapGate "qiskit.circuit.library.CSwapGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the control.
* **target\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **target\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
<Admonition title="See also" type="note">
QuantumCircuit.cswap: the same function with a different name.
</Admonition>
</Function>
### from\_instructions
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.from_instructions" signature="NumPyMatrix.from_instructions(instructions, *, qubits=(), clbits=(), name=None, global_phase=0, metadata=None)" modifiers="static">
Construct a circuit from an iterable of CircuitInstructions.
**Parameters**
* **instructions** The instructions to add to the circuit.
* **qubits** Any qubits to add to the circuit. This argument can be used, for example, to enforce a particular ordering of qubits.
* **clbits** Any classical bits to add to the circuit. This argument can be used, for example, to enforce a particular ordering of classical bits.
* **name** The name of the circuit.
* **global\_phase** The global phase of the circuit in radians.
* **metadata** Arbitrary key value metadata to associate with the circuit.
**Returns**
The quantum circuit.
</Function>
### from\_qasm\_file
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.from_qasm_file" signature="NumPyMatrix.from_qasm_file(path)" modifiers="static">
Take in a QASM file and generate a QuantumCircuit object.
**Parameters**
**path** (*str*) Path to the file for a QASM program
**Returns**
The QuantumCircuit object for the input QASM
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### from\_qasm\_str
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.from_qasm_str" signature="NumPyMatrix.from_qasm_str(qasm_str)" modifiers="static">
Take in a QASM string and generate a QuantumCircuit object.
**Parameters**
**qasm\_str** (*str*) A QASM program string
**Returns**
The QuantumCircuit object for the input QASM
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### get\_instructions
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.get_instructions" signature="NumPyMatrix.get_instructions(name)">
Get instructions matching name.
**Parameters**
**name** (*str*) The name of instruction to.
**Returns**
list of (instruction, qargs, cargs).
**Return type**
list(tuple)
</Function>
### h
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.h" signature="NumPyMatrix.h(qubit)">
Apply [`HGate`](qiskit.circuit.library.HGate "qiskit.circuit.library.HGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### hamiltonian
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.hamiltonian" signature="NumPyMatrix.hamiltonian(operator, time, qubits, label=None)">
Apply hamiltonian evolution to qubits.
</Function>
### has\_calibration\_for
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.has_calibration_for" signature="NumPyMatrix.has_calibration_for(instr_context)">
Return True if the circuit has a calibration defined for the instruction context. In this case, the operation does not need to be translated to the device basis.
</Function>
### has\_register
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.has_register" signature="NumPyMatrix.has_register(register)">
Test if this circuit has the register r.
**Parameters**
**register** (*Register*) a quantum or classical register.
**Returns**
True if the register is contained in this circuit.
**Return type**
bool
</Function>
### i
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.i" signature="NumPyMatrix.i(qubit)">
Apply [`IGate`](qiskit.circuit.library.IGate "qiskit.circuit.library.IGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### id
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.id" signature="NumPyMatrix.id(qubit)">
Apply [`IGate`](qiskit.circuit.library.IGate "qiskit.circuit.library.IGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
<Admonition title="See also" type="note">
QuantumCircuit.i: the same function.
</Admonition>
</Function>
### if\_else
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.if_else" signature="NumPyMatrix.if_else(condition, true_body, false_body, qubits, clbits, label=None)">
Apply `IfElseOp`.
<Admonition title="Note" type="note">
This method does not have an associated context-manager form, because it is already handled by the [`if_test()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_test "qiskit.algorithms.linear_solvers.NumPyMatrix.if_test") method. You can use the `else` part of that with something such as:
```python
from qiskit.circuit import QuantumCircuit, Qubit, Clbit
bits = [Qubit(), Qubit(), Clbit()]
qc = QuantumCircuit(bits)
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 0)
with qc.if_test((bits[2], 0)) as else_:
qc.h(0)
with else_:
qc.x(0)
```
</Admonition>
**Parameters**
* **condition** (`Union`\[`Tuple`\[[`ClassicalRegister`](qiskit.circuit.ClassicalRegister "qiskit.circuit.classicalregister.ClassicalRegister"), `int`], `Tuple`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit"), `int`], `Tuple`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit"), `bool`]]) A condition to be evaluated at circuit runtime which, if true, will trigger the evaluation of `true_body`. Can be specified as either a tuple of a `ClassicalRegister` to be tested for equality with a given `int`, or as a tuple of a `Clbit` to be compared to either a `bool` or an `int`.
* **true\_body** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) The circuit body to be run if `condition` is true.
* **false\_body** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) The circuit to be run if `condition` is false.
* **qubits** (`Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]]) The circuit qubits over which the if/else should be run.
* **clbits** (`Sequence`\[`Union`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit"), [`ClassicalRegister`](qiskit.circuit.ClassicalRegister "qiskit.circuit.classicalregister.ClassicalRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit"), `int`]]]]) The circuit clbits over which the if/else should be run.
* **label** (`Optional`\[`str`]) The string label of the instruction in the circuit.
**Raises**
**CircuitError** If the provided condition references Clbits outside the enclosing circuit.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instruction created.
</Function>
### if\_test
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.if_test" signature="NumPyMatrix.if_test(condition, true_body=None, qubits=None, clbits=None, *, label=None)">
Create an `if` statement on this circuit.
There are two forms for calling this function. If called with all its arguments (with the possible exception of `label`), it will create a `IfElseOp` with the given `true_body`, and there will be no branch for the `false` condition (see also the [`if_else()`](qiskit.algorithms.linear_solvers.NumPyMatrix#if_else "qiskit.algorithms.linear_solvers.NumPyMatrix.if_else") method). However, if `true_body` (and `qubits` and `clbits`) are *not* passed, then this acts as a context manager, which can be used to build `if` statements. The return value of the `with` statement is a chainable context manager, which can be used to create subsequent `else` blocks. In this form, you do not need to keep track of the qubits or clbits you are using, because the scope will handle it for you.
For example:
```python
from qiskit.circuit import QuantumCircuit, Qubit, Clbit
bits = [Qubit(), Qubit(), Qubit(), Clbit(), Clbit()]
qc = QuantumCircuit(bits)
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 0)
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 1)
with qc.if_test((bits[3], 0)) as else_:
qc.x(2)
with else_:
qc.h(2)
qc.z(2)
```
**Parameters**
* **condition** (*Tuple\[Union\[*[*ClassicalRegister*](qiskit.circuit.ClassicalRegister "qiskit.circuit.ClassicalRegister")*,* [*Clbit*](qiskit.circuit.Clbit "qiskit.circuit.Clbit")*], int]*) A condition to be evaluated at circuit runtime which, if true, will trigger the evaluation of `true_body`. Can be specified as either a tuple of a `ClassicalRegister` to be tested for equality with a given `int`, or as a tuple of a `Clbit` to be compared to either a `bool` or an `int`.
* **true\_body** (*Optional\[*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*]*) The circuit body to be run if `condition` is true.
* **qubits** (*Optional\[Sequence\[QubitSpecifier]]*) The circuit qubits over which the if/else should be run.
* **clbits** (*Optional\[Sequence\[ClbitSpecifier]]*) The circuit clbits over which the if/else should be run.
* **label** (*Optional\[str]*) The string label of the instruction in the circuit.
**Returns**
depending on the call signature, either a context manager for creating the `if` block (it will automatically be added to the circuit at the end of the block), or an `InstructionSet` handle to the appended conditional operation.
**Return type**
[InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet") or IfContext
**Raises**
* **CircuitError** If the provided condition references Clbits outside the enclosing circuit.
* **CircuitError** if an incorrect calling convention is used.
**Returns**
A handle to the instruction created.
</Function>
### initialize
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.initialize" signature="NumPyMatrix.initialize(params, qubits=None)">
Initialize qubits in a specific state.
Qubit initialization is done by first resetting the qubits to $|0\rangle$ followed by calling `qiskit.extensions.StatePreparation` class to prepare the qubits in a specified state. Both these steps are included in the [`qiskit.extensions.Initialize`](qiskit.extensions.Initialize "qiskit.extensions.Initialize") instruction.
**Parameters**
* **params** (*str or list or int*)
* str: labels of basis states of the Pauli eigenstates Z, X, Y. See [`Statevector.from_label()`](qiskit.quantum_info.Statevector#from_label "qiskit.quantum_info.Statevector.from_label"). Notice the order of the labels is reversed with respect to the qubit index to be applied to. Example label 01 initializes the qubit zero to $|1\rangle$ and the qubit one to $|0\rangle$.
* list: vector of complex amplitudes to initialize to.
* int: an integer that is used as a bitmap indicating which qubits to initialize to $|1\rangle$. Example: setting params to 5 would initialize qubit 0 and qubit 2 to $|1\rangle$ and qubit 1 to $|0\rangle$.
* **qubits** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit") *or int*)
* QuantumRegister: A list of qubits to be initialized \[Default: None].
* Qubit: Single qubit to be initialized \[Default: None].
* int: Index of qubit to be initialized \[Default: None].
* list: Indexes of qubits to be initialized \[Default: None].
**Returns**
a handle to the instruction that was just initialized
**Return type**
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
**Examples**
Prepare a qubit in the state $(|0\rangle - |1\rangle) / \sqrt{2}$.
```python
import numpy as np
from qiskit import QuantumCircuit
circuit = QuantumCircuit(1)
circuit.initialize([1/np.sqrt(2), -1/np.sqrt(2)], 0)
circuit.draw()
```
output:
```python
┌──────────────────────────────┐
q_0: ┤ Initialize(0.70711,-0.70711) ├
└──────────────────────────────┘
```
Initialize from a string two qubits in the state $|10\rangle$. The order of the labels is reversed with respect to qubit index. More information about labels for basis states are in [`Statevector.from_label()`](qiskit.quantum_info.Statevector#from_label "qiskit.quantum_info.Statevector.from_label").
```python
import numpy as np
from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.initialize('01', circuit.qubits)
circuit.draw()
```
output:
```python
┌──────────────────┐
q_0: ┤0 ├
│ Initialize(0,1) │
q_1: ┤1 ├
└──────────────────┘
```
Initialize two qubits from an array of complex amplitudes.
```python
import numpy as np
from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.initialize([0, 1/np.sqrt(2), -1.j/np.sqrt(2), 0], circuit.qubits)
circuit.draw()
```
output:
```python
┌────────────────────────────────────┐
q_0: ┤0 ├
│ Initialize(0,0.70711,-0.70711j,0) │
q_1: ┤1 ├
└────────────────────────────────────┘
```
</Function>
### inverse
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.inverse" signature="NumPyMatrix.inverse()">
Invert (take adjoint of) this circuit.
This is done by recursively inverting all gates.
**Returns**
the inverted circuit
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**CircuitError** if the circuit cannot be inverted.
**Examples**
input:
```python
┌───┐
q_0: ┤ H ├─────■──────
└───┘┌────┴─────┐
q_1: ─────┤ RX(1.57) ├
└──────────┘
```
output:
```python
┌───┐
q_0: ──────■──────┤ H ├
┌─────┴─────┐└───┘
q_1: ┤ RX(-1.57) ├─────
└───────────┘
```
</Function>
### iso
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.iso" signature="NumPyMatrix.iso(isometry, q_input, q_ancillas_for_output, q_ancillas_zero=None, q_ancillas_dirty=None, epsilon=1e-10)">
Attach an arbitrary isometry from m to n qubits to a circuit. In particular, this allows to attach arbitrary unitaries on n qubits (m=n) or to prepare any state on n qubits (m=0). The decomposition used here was introduced by Iten et al. in [https://arxiv.org/abs/1501.06911](https://arxiv.org/abs/1501.06911).
**Parameters**
* **isometry** (*ndarray*) an isometry from m to n qubits, i.e., a (complex) ndarray of dimension 2^n×2^m with orthonormal columns (given in the computational basis specified by the order of the ancillas and the input qubits, where the ancillas are considered to be more significant than the input qubits.).
* **q\_input** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of m qubits where the input to the isometry is fed in (empty list for state preparation).
* **q\_ancillas\_for\_output** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of n-m ancilla qubits that are used for the output of the isometry and which are assumed to start in the zero state. The qubits are listed with increasing significance.
* **q\_ancillas\_zero** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of ancilla qubits which are assumed to start in the zero state. Default is q\_ancillas\_zero = None.
* **q\_ancillas\_dirty** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of ancilla qubits which can start in an arbitrary state. Default is q\_ancillas\_dirty = None.
* **epsilon** (*float*) error tolerance of calculations. Default is epsilon = \_EPS.
**Returns**
the isometry is attached to the quantum circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the array is not an isometry of the correct size corresponding to the provided number of qubits.
</Function>
### isometry
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.isometry" signature="NumPyMatrix.isometry(isometry, q_input, q_ancillas_for_output, q_ancillas_zero=None, q_ancillas_dirty=None, epsilon=1e-10)">
Attach an arbitrary isometry from m to n qubits to a circuit. In particular, this allows to attach arbitrary unitaries on n qubits (m=n) or to prepare any state on n qubits (m=0). The decomposition used here was introduced by Iten et al. in [https://arxiv.org/abs/1501.06911](https://arxiv.org/abs/1501.06911).
**Parameters**
* **isometry** (*ndarray*) an isometry from m to n qubits, i.e., a (complex) ndarray of dimension 2^n×2^m with orthonormal columns (given in the computational basis specified by the order of the ancillas and the input qubits, where the ancillas are considered to be more significant than the input qubits.).
* **q\_input** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of m qubits where the input to the isometry is fed in (empty list for state preparation).
* **q\_ancillas\_for\_output** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of n-m ancilla qubits that are used for the output of the isometry and which are assumed to start in the zero state. The qubits are listed with increasing significance.
* **q\_ancillas\_zero** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of ancilla qubits which are assumed to start in the zero state. Default is q\_ancillas\_zero = None.
* **q\_ancillas\_dirty** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of ancilla qubits which can start in an arbitrary state. Default is q\_ancillas\_dirty = None.
* **epsilon** (*float*) error tolerance of calculations. Default is epsilon = \_EPS.
**Returns**
the isometry is attached to the quantum circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the array is not an isometry of the correct size corresponding to the provided number of qubits.
</Function>
### iswap
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.iswap" signature="NumPyMatrix.iswap(qubit1, qubit2)">
Apply [`iSwapGate`](qiskit.circuit.library.iSwapGate "qiskit.circuit.library.iSwapGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubits to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubits to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### mcp
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.mcp" signature="NumPyMatrix.mcp(lam, control_qubits, target_qubit)">
Apply [`MCPhaseGate`](qiskit.circuit.library.MCPhaseGate "qiskit.circuit.library.MCPhaseGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **lam** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **control\_qubits** (`Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]]) The qubits used as the controls.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### mcrx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.mcrx" signature="NumPyMatrix.mcrx(theta, q_controls, q_target, use_basis_gates=False)">
Apply Multiple-Controlled X rotation gate
**Parameters**
* **self** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) The QuantumCircuit object to apply the mcrx gate on.
* **theta** (*float*) angle theta
* **q\_controls** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or list(*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*)*) The list of control qubits
* **q\_target** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) The target qubit
* **use\_basis\_gates** (*bool*) use p, u, cx
**Raises**
**QiskitError** parameter errors
</Function>
### mcry
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.mcry" signature="NumPyMatrix.mcry(theta, q_controls, q_target, q_ancillae=None, mode=None, use_basis_gates=False)">
Apply Multiple-Controlled Y rotation gate
**Parameters**
* **self** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) The QuantumCircuit object to apply the mcry gate on.
* **theta** (*float*) angle theta
* **q\_controls** (*list(*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*)*) The list of control qubits
* **q\_target** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) The target qubit
* **q\_ancillae** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or tuple(*[*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*, int)*) The list of ancillary qubits.
* **mode** (*string*) The implementation mode to use
* **use\_basis\_gates** (*bool*) use p, u, cx
**Raises**
**QiskitError** parameter errors
</Function>
### mcrz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.mcrz" signature="NumPyMatrix.mcrz(lam, q_controls, q_target, use_basis_gates=False)">
Apply Multiple-Controlled Z rotation gate
**Parameters**
* **self** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) The QuantumCircuit object to apply the mcrz gate on.
* **lam** (*float*) angle lambda
* **q\_controls** (*list(*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*)*) The list of control qubits
* **q\_target** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) The target qubit
* **use\_basis\_gates** (*bool*) use p, u, cx
**Raises**
**QiskitError** parameter errors
</Function>
### mct
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.mct" signature="NumPyMatrix.mct(control_qubits, target_qubit, ancilla_qubits=None, mode='noancilla')">
Apply [`MCXGate`](qiskit.circuit.library.MCXGate "qiskit.circuit.library.MCXGate").
The multi-cX gate can be implemented using different techniques, which use different numbers of ancilla qubits and have varying circuit depth. These modes are:
* noancilla: Requires 0 ancilla qubits.
* recursion: Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0.
* v-chain: Requires 2 less ancillas than the number of control qubits.
* v-chain-dirty: Same as for the clean ancillas (but the circuit will be longer).
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubits** (`Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]]) The qubits used as the controls.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **ancilla\_qubits** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]], `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]], `None`]) The qubits used as the ancillae, if the mode requires them.
* **mode** (`str`) The choice of mode, explained further above.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
**Raises**
* **ValueError** if the given mode is not known, or if too few ancilla qubits are passed.
* **AttributeError** if no ancilla qubits are passed, but some are needed.
<Admonition title="See also" type="note">
QuantumCircuit.mcx: the same gate with a different name.
</Admonition>
</Function>
### mcx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.mcx" signature="NumPyMatrix.mcx(control_qubits, target_qubit, ancilla_qubits=None, mode='noancilla')">
Apply [`MCXGate`](qiskit.circuit.library.MCXGate "qiskit.circuit.library.MCXGate").
The multi-cX gate can be implemented using different techniques, which use different numbers of ancilla qubits and have varying circuit depth. These modes are:
* noancilla: Requires 0 ancilla qubits.
* recursion: Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0.
* v-chain: Requires 2 less ancillas than the number of control qubits.
* v-chain-dirty: Same as for the clean ancillas (but the circuit will be longer).
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubits** (`Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]]) The qubits used as the controls.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
* **ancilla\_qubits** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]], `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]], `None`]) The qubits used as the ancillae, if the mode requires them.
* **mode** (`str`) The choice of mode, explained further above.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
**Raises**
* **ValueError** if the given mode is not known, or if too few ancilla qubits are passed.
* **AttributeError** if no ancilla qubits are passed, but some are needed.
</Function>
### measure
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.measure" signature="NumPyMatrix.measure(qubit, cbit)">
Measure quantum bit into classical bit (tuples).
**Parameters**
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) qubit to measure.
* **cbit** (`Union`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit"), [`ClassicalRegister`](qiskit.circuit.ClassicalRegister "qiskit.circuit.classicalregister.ClassicalRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit"), `int`]]]) classical bit to place the measurement in.
**Returns**
handle to the added instructions.
**Return type**
[qiskit.circuit.InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
**Raises**
**CircuitError** if arguments have bad format.
</Function>
### measure\_active
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.measure_active" signature="NumPyMatrix.measure_active(inplace=True)">
Adds measurement to all non-idle qubits. Creates a new ClassicalRegister with a size equal to the number of non-idle qubits being measured.
Returns a new circuit with measurements if inplace=False.
**Parameters**
**inplace** (*bool*) All measurements inplace or return new circuit.
**Returns**
Returns circuit with measurements when inplace = False.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### measure\_all
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.measure_all" signature="NumPyMatrix.measure_all(inplace=True, add_bits=True)">
Adds measurement to all qubits.
By default, adds new classical bits in a [`ClassicalRegister`](qiskit.circuit.ClassicalRegister "qiskit.circuit.ClassicalRegister") to store these measurements. If `add_bits=False`, the results of the measurements will instead be stored in the already existing classical bits, with qubit `n` being measured into classical bit `n`.
Returns a new circuit with measurements if `inplace=False`.
**Parameters**
* **inplace** (*bool*) All measurements inplace or return new circuit.
* **add\_bits** (*bool*) Whether to add new bits to store the results.
**Returns**
Returns circuit with measurements when `inplace=False`.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**CircuitError** if `add_bits=False` but there are not enough classical bits.
</Function>
### ms
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ms" signature="NumPyMatrix.ms(theta, qubits)">
Apply [`MSGate`](qiskit.circuit.library.MSGate "qiskit.circuit.library.generalized_gates.gms.MSGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **qubits** (`Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]]) The qubits to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### num\_connected\_components
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_connected_components" signature="NumPyMatrix.num_connected_components(unitary_only=False)">
How many non-entangled subcircuits can the circuit be factored to.
**Parameters**
**unitary\_only** (*bool*) Compute only unitary part of graph.
**Returns**
Number of connected components in circuit.
**Return type**
int
</Function>
### num\_nonlocal\_gates
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_nonlocal_gates" signature="NumPyMatrix.num_nonlocal_gates()">
Return number of non-local gates (i.e. involving 2+ qubits).
Conditional nonlocal gates are also included.
</Function>
### num\_tensor\_factors
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_tensor_factors" signature="NumPyMatrix.num_tensor_factors()">
Computes the number of tensor factors in the unitary (quantum) part of the circuit only.
**Notes**
This is here for backwards compatibility, and will be removed in a future release of Qiskit. You should call num\_unitary\_factors instead.
**Return type**
`int`
</Function>
### num\_unitary\_factors
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_unitary_factors" signature="NumPyMatrix.num_unitary_factors()">
Computes the number of tensor factors in the unitary (quantum) part of the circuit only.
**Return type**
`int`
</Function>
### p
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.p" signature="NumPyMatrix.p(theta, qubit)">
Apply [`PhaseGate`](qiskit.circuit.library.PhaseGate "qiskit.circuit.library.PhaseGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) THe angle of the rotation.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### pauli
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.pauli" signature="NumPyMatrix.pauli(pauli_string, qubits)">
Apply [`PauliGate`](qiskit.circuit.library.PauliGate "qiskit.circuit.library.PauliGate").
**Parameters**
* **pauli\_string** (`str`) A string representing the Pauli operator to apply, e.g. XX.
* **qubits** (`Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]]) The qubits to apply this gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### power
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.power" signature="NumPyMatrix.power(power, matrix_power=False)">
Build powers of the circuit.
**Parameters**
* **power** (`int`) The power to raise this circuit to.
* **matrix\_power** (`bool`) If True, the circuit is converted to a matrix and then the matrix power is computed. If False, and `power` is a positive integer, the implementation defaults to `repeat`.
**Return type**
[`QuantumCircuit`](qiskit.circuit.QuantumCircuit "qiskit.circuit.quantumcircuit.QuantumCircuit")
**Returns**
The quantum circuit implementing powers of the unitary.
</Function>
### prepare\_state
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.prepare_state" signature="NumPyMatrix.prepare_state(state, qubits=None, label=None)">
Prepare qubits in a specific state.
This class implements a state preparing unitary. Unlike [`qiskit.extensions.Initialize`](qiskit.extensions.Initialize "qiskit.extensions.Initialize") it does not reset the qubits first.
**Parameters**
* **state** (*str or list or int or* [*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector"))
* Statevector: Statevector to initialize to.
* str: labels of basis states of the Pauli eigenstates Z, X, Y. See [`Statevector.from_label()`](qiskit.quantum_info.Statevector#from_label "qiskit.quantum_info.Statevector.from_label"). Notice the order of the labels is reversed with respect to the qubit index to be applied to. Example label 01 initializes the qubit zero to $|1\rangle$ and the qubit one to $|0\rangle$.
* list: vector of complex amplitudes to initialize to.
* int: an integer that is used as a bitmap indicating which qubits to initialize to $|1\rangle$. Example: setting params to 5 would initialize qubit 0 and qubit 2 to $|1\rangle$ and qubit 1 to $|0\rangle$.
* **qubits** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit") *or int*)
* QuantumRegister: A list of qubits to be initialized \[Default: None].
* Qubit: Single qubit to be initialized \[Default: None].
* int: Index of qubit to be initialized \[Default: None].
* list: Indexes of qubits to be initialized \[Default: None].
* **label** (*str*) An optional label for the gate
**Returns**
a handle to the instruction that was just initialized
**Return type**
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
**Examples**
Prepare a qubit in the state $(|0\rangle - |1\rangle) / \sqrt{2}$.
```python
import numpy as np
from qiskit import QuantumCircuit
circuit = QuantumCircuit(1)
circuit.prepare_state([1/np.sqrt(2), -1/np.sqrt(2)], 0)
circuit.draw()
```
output:
```python
┌─────────────────────────────────────┐
q_0: ┤ State Preparation(0.70711,-0.70711) ├
└─────────────────────────────────────┘
```
Prepare from a string two qubits in the state $|10\rangle$. The order of the labels is reversed with respect to qubit index. More information about labels for basis states are in [`Statevector.from_label()`](qiskit.quantum_info.Statevector#from_label "qiskit.quantum_info.Statevector.from_label").
```python
import numpy as np
from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.prepare_state('01', circuit.qubits)
circuit.draw()
```
output:
```python
┌─────────────────────────┐
q_0: ┤0 ├
│ State Preparation(0,1) │
q_1: ┤1 ├
└─────────────────────────┘
```
Initialize two qubits from an array of complex amplitudes .. code-block:
```python
import numpy as np
from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.prepare_state([0, 1/np.sqrt(2), -1.j/np.sqrt(2), 0], circuit.qubits)
circuit.draw()
```
output:
```python
┌───────────────────────────────────────────┐
q_0: ┤0 ├
│ State Preparation(0,0.70711,-0.70711j,0) │
q_1: ┤1 ├
└───────────────────────────────────────────┘
```
</Function>
### qasm
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.qasm" signature="NumPyMatrix.qasm(formatted=False, filename=None, encoding=None)">
Return OpenQASM string.
**Parameters**
* **formatted** (*bool*) Return formatted Qasm string.
* **filename** (*str*) Save Qasm to file with name filename.
* **encoding** (*str*) Optionally specify the encoding to use for the output file if `filename` is specified. By default this is set to the systems default encoding (ie whatever `locale.getpreferredencoding()` returns) and can be set to any valid codec or alias from stdlibs [codec module](https://docs.python.org/3/library/codecs.html#standard-encodings)
**Returns**
If formatted=False.
**Return type**
str
**Raises**
* **MissingOptionalLibraryError** If pygments is not installed and `formatted` is `True`.
* [**QasmError**](qiskit.qasm.QasmError "qiskit.qasm.QasmError") If circuit has free parameters.
</Function>
### qbit\_argument\_conversion
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.qbit_argument_conversion" signature="NumPyMatrix.qbit_argument_conversion(qubit_representation)">
Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.
**Parameters**
**qubit\_representation** (*Object*) representation to expand
**Returns**
the resolved instances of the qubits.
**Return type**
List([Qubit](qiskit.circuit.Qubit "qiskit.circuit.Qubit"))
</Function>
### qubit\_duration
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.qubit_duration" signature="NumPyMatrix.qubit_duration(*qubits)">
Return the duration between the start and stop time of the first and last instructions, excluding delays, over the supplied qubits. Its time unit is `self.unit`.
**Parameters**
**\*qubits** Qubits within `self` to include.
**Return type**
`float`
**Returns**
Return the duration between the first start and last stop time of non-delay instructions
</Function>
### qubit\_start\_time
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.qubit_start_time" signature="NumPyMatrix.qubit_start_time(*qubits)">
Return the start time of the first instruction, excluding delays, over the supplied qubits. Its time unit is `self.unit`.
Return 0 if there are no instructions over qubits
**Parameters**
* **\*qubits** Qubits within `self` to include. Integers are allowed for qubits, indicating
* **self.qubits.** (*indices of*)
**Return type**
`float`
**Returns**
Return the start time of the first instruction, excluding delays, over the qubits
**Raises**
**CircuitError** if `self` is a not-yet scheduled circuit.
</Function>
### qubit\_stop\_time
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.qubit_stop_time" signature="NumPyMatrix.qubit_stop_time(*qubits)">
Return the stop time of the last instruction, excluding delays, over the supplied qubits. Its time unit is `self.unit`.
Return 0 if there are no instructions over qubits
**Parameters**
* **\*qubits** Qubits within `self` to include. Integers are allowed for qubits, indicating
* **self.qubits.** (*indices of*)
**Return type**
`float`
**Returns**
Return the stop time of the last instruction, excluding delays, over the qubits
**Raises**
**CircuitError** if `self` is a not-yet scheduled circuit.
</Function>
### r
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.r" signature="NumPyMatrix.r(theta, phi, qubit)">
Apply [`RGate`](qiskit.circuit.library.RGate "qiskit.circuit.library.RGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **phi** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the axis of rotation in the x-y plane.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rcccx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rcccx" signature="NumPyMatrix.rcccx(control_qubit1, control_qubit2, control_qubit3, target_qubit)">
Apply [`RC3XGate`](qiskit.circuit.library.RC3XGate "qiskit.circuit.library.RC3XGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the first control.
* **control\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the second control.
* **control\_qubit3** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the third control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rccx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rccx" signature="NumPyMatrix.rccx(control_qubit1, control_qubit2, target_qubit)">
Apply [`RCCXGate`](qiskit.circuit.library.RCCXGate "qiskit.circuit.library.RCCXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the first control.
* **control\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the second control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### remove\_final\_measurements
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.remove_final_measurements" signature="NumPyMatrix.remove_final_measurements(inplace=True)">
Removes final measurements and barriers on all qubits if they are present. Deletes the classical registers that were used to store the values from these measurements that become idle as a result of this operation, and deletes classical bits that are referenced only by removed registers, or that arent referenced at all but have become idle as a result of this operation.
Measurements and barriers are considered final if they are followed by no other operations (aside from other measurements or barriers.)
**Parameters**
**inplace** (*bool*) All measurements removed inplace or return new circuit.
**Returns**
Returns the resulting circuit when `inplace=False`, else None.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### repeat
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.repeat" signature="NumPyMatrix.repeat(reps)">
Repeat this circuit `reps` times.
**Parameters**
**reps** (*int*) How often this circuit should be repeated.
**Returns**
A circuit containing `reps` repetitions of this circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### reset
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.reset" signature="NumPyMatrix.reset(qubit)">
Reset the quantum bit(s) to their default state.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) qubit(s) to reset.
**Returns**
handle to the added instruction.
**Return type**
[qiskit.circuit.InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
</Function>
### reverse\_bits
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.reverse_bits" signature="NumPyMatrix.reverse_bits()">
Return a circuit with the opposite order of wires.
The circuit is “vertically” flipped. If a circuit is defined over multiple registers, the resulting circuit will have the same registers but with their order flipped.
This method is useful for converting a circuit written in little-endian convention to the big-endian equivalent, and vice versa.
**Returns**
the circuit with reversed bit order.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Examples**
input:
```python
┌───┐
a_0: ┤ H ├──■─────────────────
└───┘┌─┴─┐
a_1: ─────┤ X ├──■────────────
└───┘┌─┴─┐
a_2: ──────────┤ X ├──■───────
└───┘┌─┴─┐
b_0: ───────────────┤ X ├──■──
└───┘┌─┴─┐
b_1: ────────────────────┤ X ├
└───┘
```
output:
```python
┌───┐
b_0: ────────────────────┤ X ├
┌───┐└─┬─┘
b_1: ───────────────┤ X ├──■──
┌───┐└─┬─┘
a_0: ──────────┤ X ├──■───────
┌───┐└─┬─┘
a_1: ─────┤ X ├──■────────────
┌───┐└─┬─┘
a_2: ┤ H ├──■─────────────────
└───┘
```
</Function>
### reverse\_ops
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.reverse_ops" signature="NumPyMatrix.reverse_ops()">
Reverse the circuit by reversing the order of instructions.
This is done by recursively reversing all instructions. It does not invert (adjoint) any gate.
**Returns**
the reversed circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Examples**
input:
```python
┌───┐
q_0: ┤ H ├─────■──────
└───┘┌────┴─────┐
q_1: ─────┤ RX(1.57) ├
└──────────┘
```
output:
```python
┌───┐
q_0: ─────■──────┤ H ├
┌────┴─────┐└───┘
q_1: ┤ RX(1.57) ├─────
└──────────┘
```
</Function>
### rv
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rv" signature="NumPyMatrix.rv(vx, vy, vz, qubit)">
Apply [`RVGate`](qiskit.circuit.library.RVGate "qiskit.circuit.library.RVGate").
For the full matrix form of this gate, see the underlying gate documentation.
Rotation around an arbitrary rotation axis $v$, where $|v|$ is the angle of rotation in radians.
**Parameters**
* **vx** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) x-compenent of the rotation axis.
* **vy** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) y-compenent of the rotation axis.
* **vz** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) z-compenent of the rotation axis.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rx" signature="NumPyMatrix.rx(theta, qubit, label=None)">
Apply [`RXGate`](qiskit.circuit.library.RXGate "qiskit.circuit.library.RXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The rotation angle of the gate.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rxx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rxx" signature="NumPyMatrix.rxx(theta, qubit1, qubit2)">
Apply [`RXXGate`](qiskit.circuit.library.RXXGate "qiskit.circuit.library.RXXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The angle of the rotation.
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### ry
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ry" signature="NumPyMatrix.ry(theta, qubit, label=None)">
Apply [`RYGate`](qiskit.circuit.library.RYGate "qiskit.circuit.library.RYGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The rotation angle of the gate.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### ryy
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ryy" signature="NumPyMatrix.ryy(theta, qubit1, qubit2)">
Apply [`RYYGate`](qiskit.circuit.library.RYYGate "qiskit.circuit.library.RYYGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The rotation angle of the gate.
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rz" signature="NumPyMatrix.rz(phi, qubit)">
Apply [`RZGate`](qiskit.circuit.library.RZGate "qiskit.circuit.library.RZGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **phi** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The rotation angle of the gate.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rzx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rzx" signature="NumPyMatrix.rzx(theta, qubit1, qubit2)">
Apply [`RZXGate`](qiskit.circuit.library.RZXGate "qiskit.circuit.library.RZXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The rotation angle of the gate.
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### rzz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.rzz" signature="NumPyMatrix.rzz(theta, qubit1, qubit2)">
Apply [`RZZGate`](qiskit.circuit.library.RZZGate "qiskit.circuit.library.RZZGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The rotation angle of the gate.
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### s
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.s" signature="NumPyMatrix.s(qubit)">
Apply [`SGate`](qiskit.circuit.library.SGate "qiskit.circuit.library.SGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### save\_amplitudes
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_amplitudes" signature="NumPyMatrix.save_amplitudes(params, label='amplitudes', pershot=False, conditional=False)">
Save complex statevector amplitudes.
**Parameters**
* **params** (*List\[int] or List\[str]*) the basis states to return amplitudes for.
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save a list of amplitudes vectors for each shot of the simulation rather than the a single amplitude vector \[Default: False].
* **conditional** (*bool*) if True save the amplitudes vector conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** if params is invalid for the specified number of qubits.
</Function>
### save\_amplitudes\_squared
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_amplitudes_squared" signature="NumPyMatrix.save_amplitudes_squared(params, label='amplitudes_squared', unnormalized=False, pershot=False, conditional=False)">
Save squared statevector amplitudes (probabilities).
**Parameters**
* **params** (*List\[int] or List\[str]*) the basis states to return amplitudes for.
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated probabilities over all shots \[Default: False].
* **pershot** (*bool*) if True save a list of probability vectors for each shot of the simulation rather than the a single amplitude vector \[Default: False].
* **conditional** (*bool*) if True save the probability vector conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** if params is invalid for the specified number of qubits.
</Function>
### save\_clifford
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_clifford" signature="NumPyMatrix.save_clifford(label='clifford', pershot=False)">
Save the current stabilizer simulator quantum state as a Clifford.
**Parameters**
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save a list of Cliffords for each shot of the simulation \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
<Admonition title="Note" type="note">
This instruction is always defined across all qubits in a circuit.
</Admonition>
</Function>
### save\_density\_matrix
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_density_matrix" signature="NumPyMatrix.save_density_matrix(qubits=None, label='density_matrix', unnormalized=False, pershot=False, conditional=False)">
Save the current simulator quantum state as a density matrix.
**Parameters**
* **qubits** (*list or None*) the qubits to save reduced density matrix on. If None the full density matrix of qubits will be saved \[Default: None].
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated or conditional accumulated density matrix over all shots \[Default: False].
* **pershot** (*bool*) if True save a list of density matrices for each shot of the simulation rather than the average over all shots \[Default: False].
* **conditional** (*bool*) if True save the average or pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### save\_expectation\_value
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_expectation_value" signature="NumPyMatrix.save_expectation_value(operator, qubits, label='expectation_value', unnormalized=False, pershot=False, conditional=False)">
Save the expectation value of a Hermitian operator.
**Parameters**
* **operator** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") *or*[*SparsePauliOp*](qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp") *or*[*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) a Hermitian operator.
* **qubits** (*list*) circuit qubits to apply instruction.
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated or conditional accumulated expectation value over all shot \[Default: False].
* **pershot** (*bool*) if True save a list of expectation values for each shot of the simulation rather than the average over all shots \[Default: False].
* **conditional** (*bool*) if True save the average or pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** if the input operator is invalid or not Hermitian.
<Admonition title="Note" type="note">
This method appends a `SaveExpectationValue` instruction to the quantum circuit.
</Admonition>
</Function>
### save\_expectation\_value\_variance
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_expectation_value_variance" signature="NumPyMatrix.save_expectation_value_variance(operator, qubits, label='expectation_value_variance', unnormalized=False, pershot=False, conditional=False)">
Save the expectation value of a Hermitian operator.
**Parameters**
* **operator** ([*Pauli*](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") *or*[*SparsePauliOp*](qiskit.quantum_info.SparsePauliOp "qiskit.quantum_info.SparsePauliOp") *or*[*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) a Hermitian operator.
* **qubits** (*list*) circuit qubits to apply instruction.
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated or conditional accumulated expectation value and variance over all shot \[Default: False].
* **pershot** (*bool*) if True save a list of expectation values and variances for each shot of the simulation rather than the average over all shots \[Default: False].
* **conditional** (*bool*) if True save the data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** if the input operator is invalid or not Hermitian.
<Admonition title="Note" type="note">
This method appends a `SaveExpectationValueVariance` instruction to the quantum circuit.
</Admonition>
</Function>
### save\_matrix\_product\_state
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_matrix_product_state" signature="NumPyMatrix.save_matrix_product_state(label='matrix_product_state', pershot=False, conditional=False)">
Save the current simulator quantum state as a matrix product state.
**Parameters**
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save the mps for each shot of the simulation \[Default: False].
* **conditional** (*bool*) if True save pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### save\_probabilities
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_probabilities" signature="NumPyMatrix.save_probabilities(qubits=None, label='probabilities', unnormalized=False, pershot=False, conditional=False)">
Save measurement outcome probabilities vector.
**Parameters**
* **qubits** (*list or None*) the qubits to apply snapshot to. If None all qubits will be snapshot \[Default: None].
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated probabilities over all shots \[Default: False].
* **pershot** (*bool*) if True save a list of probabilities for each shot of the simulation rather than the average over all shots \[Default: False].
* **conditional** (*bool*) if True save the probabilities data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### save\_probabilities\_dict
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_probabilities_dict" signature="NumPyMatrix.save_probabilities_dict(qubits=None, label='probabilities', unnormalized=False, pershot=False, conditional=False)">
Save measurement outcome probabilities vector.
**Parameters**
* **qubits** (*list or None*) the qubits to apply snapshot to. If None all qubits will be snapshot \[Default: None].
* **label** (*str*) the key for retrieving saved data from results.
* **unnormalized** (*bool*) If True return save the unnormalized accumulated probabilities over all shots \[Default: False].
* **pershot** (*bool*) if True save a list of probabilities for each shot of the simulation rather than the average over all shots \[Default: False].
* **conditional** (*bool*) if True save the probabilities data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### save\_stabilizer
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_stabilizer" signature="NumPyMatrix.save_stabilizer(label='stabilizer', pershot=False, conditional=False)">
Save the current stabilizer simulator quantum state as a StabilizerState.
**Parameters**
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save a list of StabilizerStates for each shot of the simulation \[Default: False].
* **conditional** (*bool*) if True save pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
<Admonition title="Note" type="note">
This instruction is always defined across all qubits in a circuit.
</Admonition>
</Function>
### save\_state
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_state" signature="NumPyMatrix.save_state(label=None, pershot=False, conditional=False)">
Save the current simulator quantum state.
**Parameters**
* **label** (*str or None*) Optional, the key for retrieving saved data from results. If None the key will be the state type of the simulator.
* **pershot** (*bool*) if True save a list of statevectors for each shot of the simulation \[Default: False].
* **conditional** (*bool*) if True save pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### save\_statevector
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_statevector" signature="NumPyMatrix.save_statevector(label='statevector', pershot=False, conditional=False)">
Save the current simulator quantum state as a statevector.
**Parameters**
* **pershot** (*bool*) if True save a list of statevectors for each shot of the simulation \[Default: False].
* **label** (*str*) the key for retrieving saved data from results.
* **conditional** (*bool*) if True save pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
<Admonition title="Note" type="note">
This instruction is always defined across all qubits in a circuit.
</Admonition>
</Function>
### save\_statevector\_dict
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_statevector_dict" signature="NumPyMatrix.save_statevector_dict(label='statevector', pershot=False, conditional=False)">
Save the current simulator quantum state as a statevector as a dict.
**Parameters**
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save a list of statevectors for each shot of the simulation \[Default: False].
* **conditional** (*bool*) if True save pershot data conditional on the current classical register values \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
<Admonition title="Note" type="note">
This instruction is always defined across all qubits in a circuit.
</Admonition>
</Function>
### save\_superop
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_superop" signature="NumPyMatrix.save_superop(label='superop', pershot=False)">
Save the current state of the superop simulator.
**Parameters**
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save a list of SuperOp matrices for each shot of the simulation \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
<Admonition title="Note" type="note">
This instruction is always defined across all qubits in a circuit.
</Admonition>
</Function>
### save\_unitary
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.save_unitary" signature="NumPyMatrix.save_unitary(label='unitary', pershot=False)">
Save the current state of the unitary simulator.
**Parameters**
* **label** (*str*) the key for retrieving saved data from results.
* **pershot** (*bool*) if True save a list of unitaries for each shot of the simulation \[Default: False].
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
<Admonition title="Note" type="note">
This instruction is always defined across all qubits in a circuit.
</Admonition>
</Function>
### sdg
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.sdg" signature="NumPyMatrix.sdg(qubit)">
Apply [`SdgGate`](qiskit.circuit.library.SdgGate "qiskit.circuit.library.SdgGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### set\_density\_matrix
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.set_density_matrix" signature="NumPyMatrix.set_density_matrix(state)">
Set the density matrix state of the simulator.
**Parameters**
**state** ([*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.DensityMatrix")) a density matrix.
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** If the density matrix is the incorrect size for the current circuit.
</Function>
### set\_matrix\_product\_state
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.set_matrix_product_state" signature="NumPyMatrix.set_matrix_product_state(state)">
Set the matrix product state of the simulator.
**Parameters**
**state** (*Tuple\[List\[Tuple\[np.array\[complex\_t]]]], List\[List\[float]]*) A matrix\_product\_state.
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** If the structure of the state is incorrect
</Function>
### set\_stabilizer
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.set_stabilizer" signature="NumPyMatrix.set_stabilizer(state)">
Set the Clifford stabilizer state of the simulator.
**Parameters**
**state** ([*Clifford*](qiskit.quantum_info.Clifford "qiskit.quantum_info.Clifford")) A clifford operator.
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** If the state is the incorrect size for the current circuit.
</Function>
### set\_statevector
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.set_statevector" signature="NumPyMatrix.set_statevector(state)">
Set the statevector state of the simulator.
**Parameters**
**state** ([*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector")) A state matrix.
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** If the state is the incorrect size for the current circuit.
</Function>
### set\_superop
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.set_superop" signature="NumPyMatrix.set_superop(state)">
Set the superop state of the simulator.
**Parameters**
**state** (*QuantumChannel*) A CPTP quantum channel.
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
* **ExtensionError** If the state is the incorrect size for the current circuit.
* **ExtensionError** if the input QuantumChannel is not CPTP.
</Function>
### set\_unitary
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.set_unitary" signature="NumPyMatrix.set_unitary(state)">
Set the state state of the simulator.
**Parameters**
**state** ([*Operator*](qiskit.quantum_info.Operator "qiskit.quantum_info.Operator")) A state matrix.
**Returns**
with attached instruction.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
* **ExtensionError** If the state is the incorrect size for the current circuit.
* **ExtensionError** if the input matrix is not unitary.
</Function>
### size
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.size" signature="NumPyMatrix.size(*args, **kwargs)">
Returns total number of instructions in circuit.
**Parameters**
**filter\_function** (*callable*) a function to filter out some instructions. Should take as input a tuple of (Instruction, list(Qubit), list(Clbit)). By default filters out “directives”, such as barrier or snapshot.
**Returns**
Total number of gate operations.
**Return type**
int
</Function>
### snapshot
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.snapshot" signature="NumPyMatrix.snapshot(label, snapshot_type='statevector', qubits=None, params=None)">
Take a statevector snapshot of the internal simulator representation. Works on all qubits, and prevents reordering (like barrier).
For other types of snapshots use the Snapshot extension directly.
**Parameters**
* **label** (*str*) a snapshot label to report the result.
* **snapshot\_type** (*str*) the type of the snapshot.
* **qubits** (*list or None*) the qubits to apply snapshot to \[Default: None].
* **params** (*list or None*) the parameters for snapshot\_type \[Default: None].
**Returns**
with attached command
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**ExtensionError** malformed command
</Function>
### squ
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.squ" signature="NumPyMatrix.squ(unitary_matrix, qubit, mode='ZYZ', up_to_diagonal=False)">
Decompose an arbitrary 2\*2 unitary into three rotation gates.
Note that the decomposition is up to a global phase shift. (This is a well known decomposition which can be found for example in Nielsen and Chuangs book “Quantum computation and quantum information”.)
**Parameters**
* **unitary\_matrix** (*ndarray*) 2\*2 unitary (given as a (complex) ndarray).
* **qubit** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister") *or*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) The qubit which the gate is acting on.
* **mode** (*string*) determines the used decomposition by providing the rotation axes. The allowed modes are: “ZYZ” (default)
* **up\_to\_diagonal** (*bool*) if set to True, the single-qubit unitary is decomposed up to a diagonal matrix, i.e. a unitary u is implemented such that there exists a 2\*2 diagonal gate d with u = d.dot(u)
**Returns**
The single-qubit unitary instruction attached to the circuit.
**Return type**
[InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet")
**Raises**
**QiskitError** if the format is wrong; if the array u is not unitary
</Function>
### swap
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.swap" signature="NumPyMatrix.swap(qubit1, qubit2)">
Apply [`SwapGate`](qiskit.circuit.library.SwapGate "qiskit.circuit.library.SwapGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubits to apply the gate to.
* **qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubits to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### sx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.sx" signature="NumPyMatrix.sx(qubit)">
Apply [`SXGate`](qiskit.circuit.library.SXGate "qiskit.circuit.library.SXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### sxdg
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.sxdg" signature="NumPyMatrix.sxdg(qubit)">
Apply [`SXdgGate`](qiskit.circuit.library.SXdgGate "qiskit.circuit.library.SXdgGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### t
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.t" signature="NumPyMatrix.t(qubit)">
Apply [`TGate`](qiskit.circuit.library.TGate "qiskit.circuit.library.TGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### tdg
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.tdg" signature="NumPyMatrix.tdg(qubit)">
Apply [`TdgGate`](qiskit.circuit.library.TdgGate "qiskit.circuit.library.TdgGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### tensor
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.tensor" signature="NumPyMatrix.tensor(other, inplace=False)">
Tensor `self` with `other`.
Remember that in the little-endian convention the leftmost operation will be at the bottom of the circuit. See also [the docs](qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations) for more information.
```python
┌────────┐ ┌─────┐ ┌─────┐
q_0: ┤ bottom ├ ⊗ q_0: ┤ top ├ = q_0: ─┤ top ├──
└────────┘ └─────┘ ┌┴─────┴─┐
q_1: ┤ bottom ├
└────────┘
```
**Parameters**
* **other** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) The other circuit to tensor this circuit with.
* **inplace** (*bool*) If True, modify the object. Otherwise return composed circuit.
**Examples**
```python
from qiskit import QuantumCircuit
top = QuantumCircuit(1)
top.x(0);
bottom = QuantumCircuit(2)
bottom.cry(0.2, 0, 1);
tensored = bottom.tensor(top)
tensored.draw('mpl')
```
![../\_images/qiskit-algorithms-linear\_solvers-NumPyMatrix-tensor-1.png](/images/api/qiskit/0.41/qiskit-algorithms-linear_solvers-NumPyMatrix-tensor-1.png)
**Returns**
The tensored circuit (returns None if inplace==True).
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
</Function>
### to\_gate
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.to_gate" signature="NumPyMatrix.to_gate(parameter_map=None, label=None)">
Create a Gate out of this circuit.
**Parameters**
* **parameter\_map** (*dict*) For parameterized circuits, a mapping from parameters in the circuit to parameters to be used in the gate. If None, existing circuit parameters will also parameterize the gate.
* **label** (*str*) Optional gate label.
**Returns**
a composite gate encapsulating this circuit (can be decomposed back)
**Return type**
[Gate](qiskit.circuit.Gate "qiskit.circuit.Gate")
</Function>
### to\_instruction
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.to_instruction" signature="NumPyMatrix.to_instruction(parameter_map=None, label=None)">
Create an Instruction out of this circuit.
**Parameters**
* **parameter\_map** (*dict*) For parameterized circuits, a mapping from parameters in the circuit to parameters to be used in the instruction. If None, existing circuit parameters will also parameterize the instruction.
* **label** (*str*) Optional gate label.
**Returns**
a composite instruction encapsulating this circuit (can be decomposed back)
**Return type**
[qiskit.circuit.Instruction](qiskit.circuit.Instruction "qiskit.circuit.Instruction")
</Function>
### toffoli
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.toffoli" signature="NumPyMatrix.toffoli(control_qubit1, control_qubit2, target_qubit)">
Apply [`CCXGate`](qiskit.circuit.library.CCXGate "qiskit.circuit.library.CCXGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **control\_qubit1** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the first control.
* **control\_qubit2** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) used as the second control.
* **target\_qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) targeted by the gate.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
<Admonition title="See also" type="note">
QuantumCircuit.ccx: the same gate with a different name.
</Admonition>
</Function>
### u
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.u" signature="NumPyMatrix.u(theta, phi, lam, qubit)">
Apply [`UGate`](qiskit.circuit.library.UGate "qiskit.circuit.library.UGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **theta** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The $\theta$ rotation angle of the gate.
* **phi** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The $\phi$ rotation angle of the gate.
* **lam** (`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]) The $\lambda$ rotation angle of the gate.
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### uc
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.uc" signature="NumPyMatrix.uc(gate_list, q_controls, q_target, up_to_diagonal=False)">
Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.
The decomposition was introduced by Bergholm et al. in [https://arxiv.org/pdf/quant-ph/0410066.pdf](https://arxiv.org/pdf/quant-ph/0410066.pdf).
**Parameters**
* **gate\_list** (*list\[ndarray]*) list of two qubit unitaries \[U\_0,…,U\_\{2^k-1}], where each single-qubit unitary U\_i is a given as a 2\*2 array
* **q\_controls** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[(*[*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*,int)]*) list of k control qubits. The qubits are ordered according to their significance in the computational basis. For example if q\_controls=\[q\[1],q\[2]] (with q = QuantumRegister(2)), the unitary U\_0 is performed if q\[1] and q\[2] are in the state zero, U\_1 is performed if q\[2] is in the state zero and q\[1] is in the state one, and so on
* **q\_target** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|(*[*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*,int)*) target qubit, where we act on with the single-qubit gates.
* **up\_to\_diagonal** (*bool*) If set to True, the uniformly controlled gate is decomposed up to a diagonal gate, i.e. a unitary u is implemented such that there exists a diagonal gate d with u = d.dot(u), where the unitary u describes the uniformly controlled gate
**Returns**
the uniformly controlled gate is attached to the circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
</Function>
### ucrx
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ucrx" signature="NumPyMatrix.ucrx(angle_list, q_controls, q_target)">
Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit.
The decomposition is base on [https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf) by Shende et al.
**Parameters**
* **angle\_list** (*list*) list of (real) rotation angles $[a_0,...,a_{2^k-1}]$
* **q\_controls** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list*) list of k control qubits (or empty list if no controls). The control qubits are ordered according to their significance in increasing order: For example if `q_controls=[q[0],q[1]]` (with `q = QuantumRegister(2)`), the rotation `Rx(a_0)` is performed if `q[0]` and `q[1]` are in the state zero, the rotation `Rx(a_1)` is performed if `q[0]` is in the state one and `q[1]` is in the state zero, and so on
* **q\_target** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) target qubit, where we act on with the single-qubit rotation gates
**Returns**
the uniformly controlled rotation gate is attached to the circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
</Function>
### ucry
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ucry" signature="NumPyMatrix.ucry(angle_list, q_controls, q_target)">
Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit.
The decomposition is base on [https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf) by Shende et al.
**Parameters**
* **angle\_list** (*list\[numbers*) list of (real) rotation angles $[a_0,...,a_{2^k-1}]$
* **q\_controls** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of k control qubits (or empty list if no controls). The control qubits are ordered according to their significance in increasing order: For example if `q_controls=[q[0],q[1]]` (with `q = QuantumRegister(2)`), the rotation `Ry(a_0)` is performed if `q[0]` and `q[1]` are in the state zero, the rotation `Ry(a_1)` is performed if `q[0]` is in the state one and `q[1]` is in the state zero, and so on
* **q\_target** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) target qubit, where we act on with the single-qubit rotation gates
**Returns**
the uniformly controlled rotation gate is attached to the circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
</Function>
### ucrz
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.ucrz" signature="NumPyMatrix.ucrz(angle_list, q_controls, q_target)">
Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit.
The decomposition is base on [https://arxiv.org/pdf/quant-ph/0406176.pdf](https://arxiv.org/pdf/quant-ph/0406176.pdf) by Shende et al.
**Parameters**
* **angle\_list** (*list\[numbers*) list of (real) rotation angles \[a\_0,…,a\_\{2^k-1}]
* **q\_controls** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|list\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]*) list of k control qubits (or empty list if no controls). The control qubits are ordered according to their significance in increasing order: For example if q\_controls=\[q\[1],q\[2]] (with q = QuantumRegister(2)), the rotation Rz(a\_0)is performed if q\[1] and q\[2] are in the state zero, the rotation Rz(a\_1) is performed if q\[1] is in the state one and q\[2] is in the state zero, and so on
* **q\_target** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")*|*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")) target qubit, where we act on with the single-qubit rotation gates
**Returns**
the uniformly controlled rotation gate is attached to the circuit.
**Return type**
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
**Raises**
**QiskitError** if the list number of control qubits does not correspond to the provided number of single-qubit unitaries; if an input is of the wrong type
</Function>
### unitary
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.unitary" signature="NumPyMatrix.unitary(obj, qubits, label=None)">
Apply unitary gate specified by `obj` to `qubits`.
**Example**
Apply a gate specified by a unitary matrix to a quantum circuit
```python
from qiskit import QuantumCircuit
matrix = [[0, 0, 0, 1],
[0, 0, 1, 0],
[1, 0, 0, 0],
[0, 1, 0, 0]]
circuit = QuantumCircuit(2)
circuit.unitary(matrix, [0, 1])
```
</Function>
### while\_loop
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.while_loop" signature="NumPyMatrix.while_loop(condition, body=None, qubits=None, clbits=None, *, label=None)">
Create a `while` loop on this circuit.
There are two forms for calling this function. If called with all its arguments (with the possible exception of `label`), it will create a `WhileLoopOp` with the given `body`. If `body` (and `qubits` and `clbits`) are *not* passed, then this acts as a context manager, which will automatically build a `WhileLoopOp` when the scope finishes. In this form, you do not need to keep track of the qubits or clbits you are using, because the scope will handle it for you.
Example usage:
```python
from qiskit.circuit import QuantumCircuit, Clbit, Qubit
bits = [Qubit(), Qubit(), Clbit()]
qc = QuantumCircuit(bits)
with qc.while_loop((bits[2], 0)):
qc.h(0)
qc.cx(0, 1)
qc.measure(0, 0)
```
**Parameters**
* **condition** (*Tuple\[Union\[*[*ClassicalRegister*](qiskit.circuit.ClassicalRegister "qiskit.circuit.ClassicalRegister")*,* [*Clbit*](qiskit.circuit.Clbit "qiskit.circuit.Clbit")*], int]*) An equality condition to be checked prior to executing `body`. The left-hand side of the condition must be a `ClassicalRegister` or a `Clbit`, and the right-hand side must be an integer or boolean.
* **body** (*Optional\[*[*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*]*) The loop body to be repeatedly executed. Omit this to use the context-manager mode.
* **qubits** (*Optional\[Sequence\[*[*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.Qubit")*]]*) The circuit qubits over which the loop body should be run. Omit this to use the context-manager mode.
* **clbits** (*Optional\[Sequence\[*[*Clbit*](qiskit.circuit.Clbit "qiskit.circuit.Clbit")*]]*) The circuit clbits over which the loop body should be run. Omit this to use the context-manager mode.
* **label** (*Optional\[str]*) The string label of the instruction in the circuit.
**Returns**
If used in context-manager mode, then this should be used as a `with` resource, which will infer the block content and operands on exit. If the full form is used, then this returns a handle to the instructions created.
**Return type**
[InstructionSet](qiskit.circuit.InstructionSet "qiskit.circuit.InstructionSet") or WhileLoopContext
**Raises**
**CircuitError** if an incorrect calling convention is used.
</Function>
### width
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.width" signature="NumPyMatrix.width()">
Return number of qubits plus clbits in circuit.
**Returns**
Width of circuit.
**Return type**
int
</Function>
### x
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.x" signature="NumPyMatrix.x(qubit, label=None)">
Apply [`XGate`](qiskit.circuit.library.XGate "qiskit.circuit.library.XGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
* **qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
* **label** (`Optional`\[`str`]) The string label of the gate in the circuit.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### y
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.y" signature="NumPyMatrix.y(qubit)">
Apply [`YGate`](qiskit.circuit.library.YGate "qiskit.circuit.library.YGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
### z
<Function id="qiskit.algorithms.linear_solvers.NumPyMatrix.z" signature="NumPyMatrix.z(qubit)">
Apply [`ZGate`](qiskit.circuit.library.ZGate "qiskit.circuit.library.ZGate").
For the full matrix form of this gate, see the underlying gate documentation.
**Parameters**
**qubit** (`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.quantumregister.QuantumRegister"), `int`, `slice`, `Sequence`\[`Union`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit"), `int`]]]) The qubit(s) to apply the gate to.
**Return type**
[`InstructionSet`](qiskit.circuit.InstructionSet "qiskit.circuit.instructionset.InstructionSet")
**Returns**
A handle to the instructions created.
</Function>
## Attributes
### ancillas
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.ancillas">
Returns a list of ancilla bits in the order that the registers were added.
**Return type**
`List`\[[`AncillaQubit`](qiskit.circuit.AncillaQubit "qiskit.circuit.quantumregister.AncillaQubit")]
</Attribute>
### calibrations
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.calibrations">
Return calibration dictionary.
The custom pulse definition of a given gate is of the form `{'gate_name': {(qubits, params): schedule}}`
**Return type**
`dict`
</Attribute>
### clbits
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.clbits">
Returns a list of classical bits in the order that the registers were added.
**Return type**
`List`\[[`Clbit`](qiskit.circuit.Clbit "qiskit.circuit.classicalregister.Clbit")]
</Attribute>
### data
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.data" />
### evolution\_time
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.evolution_time">
Return the time of the evolution.
**Return type**
`float`
</Attribute>
### extension\_lib
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.extension_lib" attributeValue="'include &#x22;qelib1.inc&#x22;;'" />
### global\_phase
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.global_phase">
Return the global phase of the circuit in radians.
**Return type**
`Union`\[[`ParameterExpression`](qiskit.circuit.ParameterExpression "qiskit.circuit.parameterexpression.ParameterExpression"), `float`]
</Attribute>
### header
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.header" attributeValue="'OPENQASM 2.0;'" />
### instances
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.instances" attributeValue="1993" />
### matrix
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.matrix">
Return the matrix.
**Return type**
`ndarray`
</Attribute>
### metadata
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.metadata">
The user provided metadata associated with the circuit
The metadata for the circuit is a user provided `dict` of metadata for the circuit. It will not be used to influence the execution or operation of the circuit, but it is expected to be passed between all transforms of the circuit (ie transpilation) and that providers will associate any circuit metadata with the results it returns from execution of that circuit.
**Return type**
`dict`
</Attribute>
### num\_ancillas
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_ancillas">
Return the number of ancilla qubits.
**Return type**
`int`
</Attribute>
### num\_clbits
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_clbits">
Return number of classical bits.
**Return type**
`int`
</Attribute>
### num\_parameters
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_parameters">
**Return type**
`int`
</Attribute>
### num\_qubits
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_qubits">
Return number of qubits.
**Return type**
`int`
</Attribute>
### num\_state\_qubits
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.num_state_qubits">
The number of state qubits representing the state $|x\rangle$.
**Return type**
`int`
**Returns**
The number of state qubits.
</Attribute>
### op\_start\_times
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.op_start_times">
Return a list of operation start times.
This attribute is enabled once one of scheduling analysis passes runs on the quantum circuit.
**Return type**
`List`\[`int`]
**Returns**
List of integers representing instruction start times. The index corresponds to the index of instruction in `QuantumCircuit.data`.
**Raises**
**AttributeError** When circuit is not scheduled.
</Attribute>
### parameters
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.parameters">
**Return type**
`ParameterView`
</Attribute>
### prefix
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.prefix" attributeValue="'circuit'" />
### qregs
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.qregs">
A list of the quantum registers associated with the circuit.
</Attribute>
### qubits
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.qubits">
Returns a list of quantum bits in the order that the registers were added.
**Return type**
`List`\[[`Qubit`](qiskit.circuit.Qubit "qiskit.circuit.quantumregister.Qubit")]
</Attribute>
### tolerance
<Attribute id="qiskit.algorithms.linear_solvers.NumPyMatrix.tolerance">
Return the error tolerance
**Return type**
`float`
</Attribute>
</Class>