How to use the blueqat.gate.OneQubitGate function in blueqat

To help you get started, we’ve selected a few blueqat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Blueqat / Blueqat / blueqat / gate.py View on Github external
class XGate(OneQubitGate):
    """Pauli's X Gate"""
    lowername = "x"


class YGate(OneQubitGate):
    """Pauli's Y Gate"""
    lowername = "y"


class ZGate(OneQubitGate):
    """Pauli's Z Gate"""
    lowername = "z"


class HGate(OneQubitGate):
    """Hadamard Gate"""
    lowername = "h"


class CZGate(TwoQubitGate):
    """Control-Z gate"""
    lowername = "cz"


class CXGate(TwoQubitGate):
    """Control-X (CNOT) Gate"""
    lowername = "cx"


class RXGate(OneQubitGate):
    """Rotate-X gate"""
github Blueqat / Blueqat / blueqat / gate.py View on Github external
class IGate(OneQubitGate):
    """Identity Gate"""
    lowername = "i"

    def fallback(self, n_qubits):
        return []


class XGate(OneQubitGate):
    """Pauli's X Gate"""
    lowername = "x"


class YGate(OneQubitGate):
    """Pauli's Y Gate"""
    lowername = "y"


class ZGate(OneQubitGate):
    """Pauli's Z Gate"""
    lowername = "z"


class HGate(OneQubitGate):
    """Hadamard Gate"""
    lowername = "h"


class CZGate(TwoQubitGate):
    """Control-Z gate"""
github Blueqat / Blueqat / blueqat / gate.py View on Github external
def _make_fallback_for_control_target_iter(self, n_qubits, fallback):
        gates = []
        for c, t in self.control_target_iter(n_qubits):
            gates += fallback(c, t)
        return gates


class IGate(OneQubitGate):
    """Identity Gate"""
    lowername = "i"

    def fallback(self, n_qubits):
        return []


class XGate(OneQubitGate):
    """Pauli's X Gate"""
    lowername = "x"


class YGate(OneQubitGate):
    """Pauli's Y Gate"""
    lowername = "y"


class ZGate(OneQubitGate):
    """Pauli's Z Gate"""
    lowername = "z"


class HGate(OneQubitGate):
    """Hadamard Gate"""
github Blueqat / Blueqat / blueqat / gate.py View on Github external
super().__init__(targets, (theta,), **kwargs)
        self.theta = theta

    def _str_args(self):
        return f'({self.theta})'


class TGate(OneQubitGate):
    """T ($\\pi/8$) gate"""
    lowername = "t"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, math.pi / 4)])


class TDagGate(OneQubitGate):
    """Dagger of T ($\\pi/8$) gate"""
    lowername = "tdg"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, -math.pi / 4)])


class SGate(OneQubitGate):
    """S gate"""
    lowername = "s"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, math.pi / 2)])


class SDagGate(OneQubitGate):
github Blueqat / Blueqat / blueqat / gate.py View on Github external
class HGate(OneQubitGate):
    """Hadamard Gate"""
    lowername = "h"


class CZGate(TwoQubitGate):
    """Control-Z gate"""
    lowername = "cz"


class CXGate(TwoQubitGate):
    """Control-X (CNOT) Gate"""
    lowername = "cx"


class RXGate(OneQubitGate):
    """Rotate-X gate"""
    lowername = "rx"

    def __init__(self, targets, theta, **kwargs):
        super().__init__(targets, (theta,), **kwargs)
        self.theta = theta

    def _str_args(self):
        return f'({self.theta})'


class RYGate(OneQubitGate):
    """Rotate-Y gate"""
    lowername = "ry"

    def __init__(self, targets, theta, **kwargs):
github Blueqat / Blueqat / blueqat / gate.py View on Github external
def fallback(self, n_qubits):
        return []


class XGate(OneQubitGate):
    """Pauli's X Gate"""
    lowername = "x"


class YGate(OneQubitGate):
    """Pauli's Y Gate"""
    lowername = "y"


class ZGate(OneQubitGate):
    """Pauli's Z Gate"""
    lowername = "z"


class HGate(OneQubitGate):
    """Hadamard Gate"""
    lowername = "h"


class CZGate(TwoQubitGate):
    """Control-Z gate"""
    lowername = "cz"


class CXGate(TwoQubitGate):
    """Control-X (CNOT) Gate"""
github Blueqat / Blueqat / blueqat / gate.py View on Github external
"""T ($\\pi/8$) gate"""
    lowername = "t"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, math.pi / 4)])


class TDagGate(OneQubitGate):
    """Dagger of T ($\\pi/8$) gate"""
    lowername = "tdg"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, -math.pi / 4)])


class SGate(OneQubitGate):
    """S gate"""
    lowername = "s"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, math.pi / 2)])


class SDagGate(OneQubitGate):
    """Dagger of S gate"""
    lowername = "sdg"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, -math.pi / 2)])


class CRXGate(TwoQubitGate):
github Blueqat / Blueqat / blueqat / gate.py View on Github external
TGate(c2),
            TGate(t),
            HGate(t),
            CXGate((c1, c2)),
            TGate(c1),
            TDagGate(c2),
            CXGate((c1, c2)),
        ]


class CCZGate(Gate):
    """2-Controlled Z gate"""
    lowername = "ccz"


class U1Gate(OneQubitGate):
    """U1 gate"""
    def __init__(self, targets, lambd, **kwargs):
        super().__init__(targets, (lambd,), **kwargs)
        self.lambd = lambd

    lowername = "u1"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(
            n_qubits, lambda t: [U3Gate(t, 0.0, 0.0, self.lambd)])


class U2Gate(OneQubitGate):
    """U2 gate"""
    def __init__(self, targets, phi, lambd, **kwargs):
        super().__init__(targets, (phi, lambd), **kwargs)
github Blueqat / Blueqat / blueqat / backends / qgate_backend.py View on Github external
def convert_one_qubit_gate(self, gate, typeinfo) :
        glist = list()

        if typeinfo[1] == 0 :
            # no control bit
            assert isinstance(gate, bqgate.OneQubitGate)
            one_qubit_gates = self.create_gates(typeinfo[0], gate)
            # "tdg": gate.TDagGate, "sdg": gate.SDagGate,
            if gate.lowername[1:] == 'dg' :
                for qg in one_qubit_gates :
                    qg.set_adjoint(True)
            glist += one_qubit_gates
        else :
            if isinstance(gate, bqgate.TwoQubitGate) :
                # controlled gate
                for ctrlidx, qregidx in gate.control_target_iter(self.n_qubits) :
                    gt = typeinfo[0](*gate.params)
                    g = model.Gate(gt)
                    ctrl = self.qregs[ctrlidx]
                    qreg = self.qregs[qregidx]
                    g.set_ctrllist(ctrl)
                    g.set_qreg(qreg)
github Blueqat / Blueqat / blueqat / gate.py View on Github external
"""Dagger of T ($\\pi/8$) gate"""
    lowername = "tdg"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, -math.pi / 4)])


class SGate(OneQubitGate):
    """S gate"""
    lowername = "s"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, math.pi / 2)])


class SDagGate(OneQubitGate):
    """Dagger of S gate"""
    lowername = "sdg"

    def fallback(self, n_qubits):
        return self._make_fallback_for_target_iter(n_qubits, lambda t: [RZGate(t, -math.pi / 2)])


class CRXGate(TwoQubitGate):
    """Rotate-X gate"""
    lowername = "crx"

    def __init__(self, targets, theta, **kwargs):
        super().__init__(targets, (theta,), **kwargs)
        self.theta = theta

    def _str_args(self):