Commit 4986a3a
[WIP] Adding `qml.OutPoly' (#6320)
To do:
- [x] Final review
- [x] Add thumbnail
- [x] Add changeling
In this PR we add `qml.OutPoly`. An operator that allows to apply
arbitrary polynomials on quantum registers.
Example where we want to create the operator:
$$U|x\rangle |y\rangle |0\rangle = |x\rangle |y\rangle |x^2 + y\rangle$$
```python
import pennylane as qml
x_wires = [0, 1, 2]
y_wires = [3, 4, 5]
output_wires = [6, 7, 8]
def f(x, y):
return x ** 2 + y
@qml.qnode(qml.device("default.qubit", shots = 1))
def circuit():
# loading values for x and y
qml.BasisEmbedding(2, wires=x_wires)
qml.BasisEmbedding(2 , wires=y_wires)
# applying the polynomial
qml.OutPoly(f,
input_registers = [x_wires, y_wires],
output_wires=output_wires)
return qml.sample(wires=output_wires)
print(circuit())
```
**Context:**
This operator is born of the quantum arithmetic project
**Benefits:**
complete flexibility for the user to create new arithmetic operators
[[sc-72629](https://app.shortcut.com/xanaduai/story/72629/support-polynomial-arithmetic)]
---------
Co-authored-by: Utkarsh <utkarshazad98@gmail.com>
Co-authored-by: Will <wmaxwell90@gmail.com>
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Co-authored-by: soranjh <40344468+soranjh@users.noreply.github.com>1 parent 630cf78 commit 4986a3a
File tree
8 files changed
+716
-1
lines changed- doc
- _static/templates/arithmetic
- introduction
- releases
- pennylane/templates/subroutines
- tests
- capture
- templates/test_subroutines
8 files changed
+716
-1
lines changedLoading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
0 commit comments