Skip to content

Piecewise Linear Rotation Amplitude Loading

The piecewise linear rotation amplitude loading function performs the following operation:

\(|d\rangle |0\rangle \rightarrow \cos{f(d)}|d\rangle |0\rangle + \sin{f(d)}|d\rangle |1\rangle\)

for any input, \(|d\rangle\), and a function \(f(d)\) that is piecewise linear. The linear functions and the transitions between them are defined by the affine_maps and breakpointsfields, respectively. These are expected to be ordered with breakpoints[0] = 0 and breakpoints[-1] = 2**num_qubits - 1, the maximal qubit index. Each linear function is defined by an AffineMap object, that has two attributes - offset and slope. For example, AffineMap(offset=a, slope=b) represents f(x) = a + bx.

Syntax

Function: PiecewiseLinearRotationAmplitudeLoading

Parameters:

  • num_qubits: PositiveInt
  • breakpoints: List[NonNegativeInt]
  • affine_maps: List[AffineMap]

Example

{
  "functions": [
    {
      "name": "main",
      "body": [
          {
              "function": "PiecewiseLinearRotationAmplitudeLoading",
              "function_params": {
                  "num_qubits": 3,
                  "breakpoints": [0, 3, 7],
                  "affine_maps": [
                    {"offset": 0, "slope": 0},
                    {"offset": -3, "slope": 1}
                  ]
              }
          }
      ]
    }
  ]
}
from classiq.builtin_functions import PiecewiseLinearRotationAmplitudeLoading
from classiq import Model, synthesize

model = Model()
amplitude_loading_params = PiecewiseLinearRotationAmplitudeLoading(
    num_qubits=3,
    breakpoints=[0, 3, 7],
    affine_maps=[{"offset": 0, "slope": 0}, {"offset": -3, "slope": 1}],
)
model.PiecewiseLinearRotationAmplitudeLoading(amplitude_loading_params)
qprog = synthesize(model.get_model())