# (C) Copyright IBM 2024.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Givens rotation ansatz gate."""from__future__importannotationsimportmathfromcollections.abcimportIterator,Sequenceimportnumpyasnpfromqiskit.circuitimport(CircuitInstruction,Gate,QuantumCircuit,QuantumRegister,Qubit,)fromqiskit.circuit.libraryimportPhaseGate,XXPlusYYGatefromffsim.variationalimportGivensAnsatzOp
[docs]classGivensAnsatzOpJW(Gate):"""Givens rotation ansatz operator under the Jordan-Wigner transformation. See :class:`ffsim.GivensAnsatzOp` for a description of this gate's unitary. """
[docs]def__init__(self,givens_ansatz_op:GivensAnsatzOp,*,label:str|None=None):"""Create a new Givens ansatz operator gate. Args: givens_ansatz_op: The Givens rotation ansatz operator. label: The label of the gate. """self.givens_ansatz_op=givens_ansatz_opsuper().__init__("givens_ansatz_jw",2*givens_ansatz_op.norb,[],label=label)
[docs]classGivensAnsatzOpSpinlessJW(Gate):"""Spinless Givens rotation ansatz operator under the Jordan-Wigner transformation. Like :class:`GivensAnsatzOpJW` but only acts on a single spin species. """
[docs]def__init__(self,givens_ansatz_op:GivensAnsatzOp,*,label:str|None=None):"""Create a new Givens ansatz operator gate. Args: givens_ansatz_op: The Givens rotation ansatz operator. label: The label of the gate. """self.givens_ansatz_op=givens_ansatz_opsuper().__init__("givens_ansatz_spinless_jw",givens_ansatz_op.norb,[],label=label)