Standard Gates¶
The Classiq platform provides many standard gates. Some key standard gates are shown here in detail. All gates are covered in the reference manual.
X Gate¶
The Pauli-X gate.
Syntax¶
Function: XGate
Parameters: None
{
"function": "XGate",
"function_params": {}
}
Y Gate¶
The Pauli-Y gate.
Syntax¶
Function: YGate
Parameters: None
{
"function": "YGate",
"function_params": {}
}
Z Gate¶
The Pauli-Z gate.
Syntax¶
Function: ZGate
Parameters: None
{
"function": "ZGate",
"function_params": {}
}
H Gate¶
The Hadamard gate converts \(|0\rangle\) to \(|+\rangle\) and \(|1\rangle\) to \(|-\rangle\).
Syntax¶
Function: HGate
Parameters: None
{
"function": "HGate",
"function_params": {}
}
RZ Gate¶
Rotation around the Z axis is by a given angle \(\varphi\).
Syntax¶
Function: RZGate
Parameters:
phi
:ParameterFloatType
The angle in a parameter type or a float.
CX Gate¶
The Controlled X gate.
Applies X Gate on the target qubit, based on the state of the control qubit (by default if the controlled state is \(|1\rangle\)).
Syntax¶
Function: CXGate
Parameters:
ctrl_state
:Optional[Union[str, PositiveOrZeroInt]]
The control state in decimal or as a bit string (e.g., ‘0’). If not specified, the control state is 1. The gate is performed if the state of the control qubits matches the control state.
{
"function": "CXGate",
"function_params": {
"ctrl_state": "0"
}
}
Example¶
This example shows a circuit built with several standard gates, both controlled and uncontrolled.
{
"logic_flow": [
{
"function": "CCXGate",
"function_params": {},
"outputs": {"CTRL": "ccx_ctrl_out", "TARGET": "ccx_target_out"}
},
{
"function": "RZGate",
"function_params": {"phi": 1.9},
"inputs": "ccx_target_out"
},
{
"function": "SwapGate",
"function_params": {},
"inputs": "ccx_ctrl_out"
}
]
}
from classiq import Model
from classiq.builtin_functions import CCXGate, SwapGate, RZGate
from classiq.model import Constraints
constraints = Constraints(max_width=4, max_depth=50)
model = Model(constraints=constraints)
ccx_params = CCXGate()
ccx_out = model.CCXGate(ccx_params)
ccx_target_out = ccx_out["TARGET"]
ccx_ctrl_out = ccx_out["CTRL"]
rz_params = RZGate(phi=1.9)
model.RZGate(rz_params, in_wires={"TARGET": ccx_target_out})
swap_params = SwapGate()
model.SwapGate(swap_params, in_wires={"TARGET": ccx_ctrl_out})
circuit = model.synthesize()
circuit.show_interactive()
Parametrized Rotations¶
Rotation gates can be performed on parameters. See Parameters.