arithmetic
arithmetic ¶
AbsoluteDisplacement ¶
Bases: Qubrick
Qubrick for computing the reciprocal of the absolute value of the difference of two vectors.
Specifically, it computes
Note
Currently, it is on the user to set the constructor args for sub-Qubricks.
A consequence of this is that if you want to allow negative values, this must be
decided when you instantiate the square sub-Qubrick inside of orthogonal_dot_product
rather than in this Qubrick's constructor. Discussions on where this decision should be made
are ongoing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orthogonal_dot_product
|
Qubrick
|
Qubrick for computing the square of a vector. |
required |
vector_sub
|
Qubrick
|
Adder Qubrick for subtracting Qubit registers. |
required |
rsqrt
|
Qubrick
|
Qubrick for performing the reciprocal square root operation. |
required |
kwargs
|
dict[str, Any]
|
Other keyword arguments for the Qubrick. |
{}
|
orthogonal_dot_product
instance-attribute
¶
compute ¶
Compute circuit for taking the absolute value of the difference between two vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q_vec1
|
list
|
List of registers encoding vector components for one vector. |
required |
q_vec2
|
list
|
List of registers encoding vector components for the other vector. |
required |
high_precision
|
(Optional, bool)
|
If True, returns high precision output from inverse square-root. Defaults to False. |
False
|
OrthogonalDotProduct ¶
Bases: Qubrick
Qubrick for squaring an n-component vector, then adding the squared results.
For example, for a 3-component vector this computes \(x^2 + y^2 + z^2\).
Note
Currently, it is on the user to set the constructor argumentss for sub-Qubricks.
A consequence of this is that if you want to allow squaring negative values,
this must be decided when you instantiate the square sub-Qubrick rather than
in this Qubrick's constructor. Discussions on where this decision should be made
are ongoing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release_ancillae
|
bool
|
Whether to release auxiliary qubits in the squaring components. |
required |
square
|
Qubrick
|
Qubrick that computes the square of a qubit register. |
required |
add
|
Qubrick
|
Adder Qubrick. |
required |
**kwargs
|
dict[str, Any]
|
Other arguments to pass to the init. |
{}
|
VectorAddition ¶
Bases: Qubrick
Qubrick for adding (or subtracting) the components of two vectors of Qubits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
add
|
Qubrick
|
Adder Qubrick. |
required |
subtract_condition
|
(Optional, bool)
|
Whether to add or subtract the two vectors. Defaults to False (addition). |
False
|
kwargs
|
dict[str, Any]
|
Other keyword arguments for the Qubrick. |
{}
|
compute ¶
Compute circuit for computing the sum (or difference) of two vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q_vec1
|
list
|
List of registers encoding vector components for one vector. |
required |
q_vec2
|
list
|
List of registers encoding vector components for the other vector. |
required |
Note
The lengths of both vectors must be equal. Currently, this Qubrick cannot handle adding registers of different sizes correctly.
Currently, this method casts the results of addition to QInt objects in order to handle
negative signs. This will be generalized.