diff --git a/pennylane_lightning/core/src/gates/Constant.hpp b/pennylane_lightning/core/src/gates/Constant.hpp index 8ec99b477b..0cb8d98c01 100644 --- a/pennylane_lightning/core/src/gates/Constant.hpp +++ b/pennylane_lightning/core/src/gates/Constant.hpp @@ -57,6 +57,7 @@ using GateView = typename std::pair; GateView{GateOperation::Hadamard, "Hadamard"}, GateView{GateOperation::S, "S"}, GateView{GateOperation::T, "T"}, + GateView{GateOperation::SX, "SX"}, GateView{GateOperation::PhaseShift, "PhaseShift"}, GateView{GateOperation::RX, "RX"}, GateView{GateOperation::RY, "RY"}, @@ -94,6 +95,7 @@ using CGateView = typename std::pair; CGateView{ControlledGateOperation::Hadamard, "Hadamard"}, CGateView{ControlledGateOperation::S, "S"}, CGateView{ControlledGateOperation::T, "T"}, + CGateView{ControlledGateOperation::SX, "SX"}, CGateView{ControlledGateOperation::PhaseShift, "PhaseShift"}, CGateView{ControlledGateOperation::RX, "RX"}, CGateView{ControlledGateOperation::RY, "RY"}, @@ -208,6 +210,7 @@ using GateNWires = typename std::pair; GateNWires{GateOperation::Hadamard, 1}, GateNWires{GateOperation::S, 1}, GateNWires{GateOperation::T, 1}, + GateNWires{GateOperation::SX, 1}, GateNWires{GateOperation::PhaseShift, 1}, GateNWires{GateOperation::RX, 1}, GateNWires{GateOperation::RY, 1}, @@ -245,6 +248,7 @@ using CGateNWires = typename std::pair; CGateNWires{ControlledGateOperation::Hadamard, 1}, CGateNWires{ControlledGateOperation::S, 1}, CGateNWires{ControlledGateOperation::T, 1}, + CGateNWires{ControlledGateOperation::SX, 1}, CGateNWires{ControlledGateOperation::PhaseShift, 1}, CGateNWires{ControlledGateOperation::RX, 1}, CGateNWires{ControlledGateOperation::RY, 1}, @@ -322,6 +326,7 @@ using GateNParams = typename std::pair; GateNParams{GateOperation::Hadamard, 0}, GateNParams{GateOperation::S, 0}, GateNParams{GateOperation::T, 0}, + GateNParams{GateOperation::SX, 0}, GateNParams{GateOperation::PhaseShift, 1}, GateNParams{GateOperation::RX, 1}, GateNParams{GateOperation::RY, 1}, @@ -364,6 +369,7 @@ using CGateNParams = typename std::pair; CGateNParams{ControlledGateOperation::S, 0}, CGateNParams{ControlledGateOperation::T, 0}, CGateNParams{ControlledGateOperation::PhaseShift, 1}, + CGateNParams{ControlledGateOperation::SX, 0}, CGateNParams{ControlledGateOperation::RX, 1}, CGateNParams{ControlledGateOperation::RY, 1}, CGateNParams{ControlledGateOperation::RZ, 1}, diff --git a/pennylane_lightning/core/src/gates/GateOperation.hpp b/pennylane_lightning/core/src/gates/GateOperation.hpp index f45b3f4e43..28b0b09c84 100644 --- a/pennylane_lightning/core/src/gates/GateOperation.hpp +++ b/pennylane_lightning/core/src/gates/GateOperation.hpp @@ -34,6 +34,7 @@ enum class GateOperation : uint32_t { Hadamard, S, T, + SX, PhaseShift, RX, RY, @@ -79,6 +80,7 @@ enum class ControlledGateOperation : uint32_t { Hadamard, S, T, + SX, PhaseShift, RX, RY, diff --git a/pennylane_lightning/core/src/gates/Gates.hpp b/pennylane_lightning/core/src/gates/Gates.hpp index 695fe34b0a..fb20c8736a 100644 --- a/pennylane_lightning/core/src/gates/Gates.hpp +++ b/pennylane_lightning/core/src/gates/Gates.hpp @@ -97,6 +97,21 @@ static constexpr auto getHadamard() -> std::vector> { INVSQRT2(), -INVSQRT2()}; } +/** + * @brief Create a matrix representation of the SX gate data in row-major + * format. + * + * @tparam ComplexT Required precision of gate (`float` or `double`). + * @return constexpr std::vector> Return constant expression + * of SX data. + */ +template