Bitwise Invert¶
The bitwise inversion operation receives a quantum register representing some number \(x\),
and inverts its binary representation, namely, replaces \(1\)s by \(0\)s and vice versa.
If the inplace
flag is set to True
, the original register is overridden by the result.
Otherwise, it is available as an output.
Syntax¶
Function: BitwiseInvert
Parameters:
arg: RegisterUserInput
(see RegisterUserInput)output_size: Optional[PositiveInt]
inplace: bool = False
Register names:
arg
:arg
result
:inverted
Example 1¶
{
"functions": [
{
"name": "main",
"body": [
{
"function": "BitwiseInvert",
"function_params": {
"arg": {"size": 7, "fraction_places": 3, "is_signed": true},
"inplace": true
}
}
]
}
]
}
from classiq import Model, RegisterUserInput, synthesize
from classiq.builtin_functions import BitwiseInvert
params = BitwiseInvert(
arg=RegisterUserInput(size=7, fraction_places=3, is_signed=True),
inplace=True,
)
model = Model()
model.BitwiseInvert(params)
quantum_program = synthesize(model.get_model())