Standard Gates¶
The Classiq platform provides many standard gates to the user. Some key standard gates will be shown here in detail. All gates can be seen 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.
This 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 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 will be performed if the state of the control qubits matches the control state.
{
"function": "CXGate",
"function_params": {
"ctrl_state": "0"
}
}
Example¶
The following 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 ModelDesigner
from classiq.builtin_functions import CCXGate, SwapGate, RZGate
from classiq.model import Constraints
constraints = Constraints(max_width=4, max_depth=50)
model_designer = ModelDesigner(constraints=constraints)
ccx_params = CCXGate()
ccx_out = model_designer.CCXGate(ccx_params)
ccx_target_out = ccx_out["TARGET"]
ccx_ctrl_out = ccx_out["CTRL"]
rz_params = RZGate(phi=1.9)
model_designer.RZGate(rz_params, in_wires={"TARGET": ccx_target_out})
swap_params = SwapGate()
model_designer.SwapGate(swap_params, in_wires={"TARGET": ccx_ctrl_out})
circuit = model_designer.synthesize()
circuit.show_interactive()
Parametrized Rotations¶
Rotation Gates can be performed on parameters. For more information please refer to Parameters user guide