-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e763d38
commit a54b0b7
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ | |
""" | ||
|
||
from .vqe import * | ||
from .hamiltonian import * | ||
from .hamiltonian import * | ||
from .qft import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import torchquantum as tq | ||
from typing import Iterable | ||
|
||
__all__ = ["QFT"] | ||
|
||
class QFT(object): | ||
def __init__( | ||
self, n_wires: int = None, wires: Iterable = None, do_swaps=True | ||
) -> None: | ||
"""Init function for QFT class | ||
Args: | ||
n_wires (int): Number of wires for the QFT as an integer | ||
wires (Iterable): Wires to perform the QFT as an Iterable | ||
add_swaps (bool): Whether or not to add the final swaps in a boolean format | ||
inverse (bool): Whether to create an inverse QFT layer in a boolean format | ||
""" | ||
super().__init__() | ||
|
||
self.n_wires = n_wires | ||
self.wires = wires | ||
self.do_swaps = do_swaps | ||
|
||
def construct_qft_circuit(self) -> tq.QuantumModule: | ||
"""Construct the QFT circuit.""" | ||
return tq.layer.QFTLayer(n_wires=self.n_wires, wires=self.wires, do_swaps=self.do_swaps) | ||
|
||
def construct_inverse_qft_circuit(self) -> tq.QuantumModule: | ||
"""Construct the inverse of a QFT circuit.""" | ||
return tq.layer.QFTLayer( | ||
n_wires=self.n_wires, wires=self.wires, do_swaps=self.do_swaps, inverse=True | ||
) |