Skip to content

User-defined Functions

The basic description of quantum algorithms in the Classiq platform can be best expressed as describing the logic flow of quantum functions. When describing the circuit model at the functional level, the user is leaving the countless design possibilities and optimizations to the synthesis engine, as well as focusing on the functional flow of the algorithm and not on the gate level implementation.

Classiq provides many useful built-in functions (see built-in function library), but for creating novel quantum algorithms, users may wish to use their own functions. A function can be any sub-circuit: a single gate, a quantum adder, an oracle, or even a fully functioning quantum circuit.

Arithmetic operations, state preparation, local Hamiltonian terms, QFT are all good examples of functions. Each function can have multiple implementations, make use of auxiliary qubits, have different numbers of input and output registers, require inputs to some of the registers, have a certain level of accuracy, and more. The more data provided about the function, the better the synthesis engine is able to create and optimize the quantum circuits.

In addition, users may use their own composite functions. Composite functions contain a functional description of the quantum algorithm it implements, using other functions as building blocks. This enables the development of increasingly complex functions, while only needing to describe the gate-level implementation of the most basic functions.

To begin, start by adding a simple function of your own based on the explanations below. From there, the possibilities are endless.