Skip to content

Inequality Mixer

The inequality mixer function performs the following operation:

\(M_{y, \theta} |x\rangle = \sum_{x' \leq y, size(x')=size(x)} \alpha_{x', \theta} |x'\rangle\), where is_less_inequality is true.

and, \(M_{y, \theta} |x\rangle = \sum_{x' \geq y, size(x')=size(x)} \alpha_{x', \theta} |x'\rangle\), where is_less_inequality is false.

I.e., after the operation is applied to registers x and y, the state in x is a superposition of all fixed-point numbers from 0 to y, or from y to \(2^{size(x)}\), depending on whether the is_less_inequality attribute is true or false, respectively.

Register x is called data_reg_input and Register y is called bound_reg_input.

The bound register can be either a quantum register or set to a fixed number.

Syntax

Function: InequalityMixer

Parameters:

Register Names

The input registers are called data_reg_input and bound_reg_input. The output registers are called data_reg_output and bound_reg_output. The bound registers are added only if the argument is from RegisterUserInput type.

These names override the original name in the RegisterUserInput objects.

Example 1: Two Registers, Less Than Mixer (x <= y)

{
  "functions": [
    {
      "name": "main",
      "body": [
          {
              "function": "InequalityMixer",
              "function_params": {
                  "data_reg_input": {"size": 3},
                  "bound_reg_input": {"size": 3},
                  "mixer_parameter": 0.4,
                  "is_less_inequality": true
              }
          }
      ]
    }
  ]
}
from classiq.builtin_functions import InequalityMixer
from classiq import Model, RegisterUserInput, synthesize

model = Model()
params = InequalityMixer(
    data_reg_input=RegisterUserInput(size=3),
    bound_reg_input=RegisterUserInput(size=3),
    mixer_parameter=0.4,
    is_less_inequality=True,
)
model.InequalityMixer(params)
quantum_program = synthesize(model.get_model())

This is the synthesized quantum program.

 Inequality_Mixer_Example

Example 2: Register and Float, Greater Than Mixer (x >= c)

{
  "functions": [
    {
      "name": "main",
      "body": [
          {
              "function": "InequalityMixer",
              "function_params": {
                  "data_reg_input": {"size": 4, "fraction_places": 1},
                  "bound_reg_input": 2.5,
                  "mixer_parameter": 0.4,
                  "is_less_inequality": false
              }
          }
      ]
    }
  ]
}
from classiq.builtin_functions import InequalityMixer
from classiq import Model, RegisterUserInput, synthesize

model = Model()
params = InequalityMixer(
    data_reg_input=RegisterUserInput(size=4, fraction_places=1),
    bound_reg_input=2.5,
    mixer_parameter=0.4,
    is_less_inequality=False,
)
model.InequalityMixer(params)
quantum_program = synthesize(model.get_model())

This is the synthesized quantum program.

 Inequality_Mixer_Example