Algorithms

Qlasskit implements high level representation of quantum algorithms that relies on black boxes functions and oracles.

  • Grover search

  • Simon periodicity

  • Deutsch Jozsa

  • Bernstein Vazirani

Abstraction tools

All algorithms share the same base class QAlgorithm which inherits from QCircuitWrapper. The QCircuitWrapper is also father of qlassf functions, and offers useful methods to handle high level types.

One of those tools is decode_counts, that translates the result dictionary from a quantum sampling in its binary form, to the high level representation of data types used in the qlasskit function; decode_output instead, translate a single bitstring.

from typing import Tuple
from qlasskit import qlassf, Qint, Qint4


@qlassf
def test_tools(a: Qint[4]) -> Qint[4]:
    return a + 1


test_tools.decode_output("0100")
4

Another method called encode_input is able to do the reverse job, transforming high level types to binary form.

test_tools.encode_input(Qint4(4))
'0100'

Simon periodicity

from qlasskit.algorithms import Simon


@qlassf
def f(a: Qint[4]) -> Qint[4]:
    return (a >> 3) + 1


q_algo = Simon(f)

Further examples can be found on the following notebooks:

Deutsch Jozsa

from qlasskit.algorithms import DeutschJozsa


@qlassf
def f(b: Qint[4]) -> bool:
    return b < 16


q_algo = DeutschJozsa(f)

Further examples can be found on the following notebooks:

Bernstein Vazirani

from qlasskit.algorithms import BernsteinVazirani, secret_oracle

oracle = secret_oracle(4, 14)

q_algo = BernsteinVazirani(oracle)

Further examples can be found on the following notebooks: