{ "cells": [ { "cell_type": "markdown", "id": "2953ed5d-b54c-41a7-8b01-11e9f4ffebea", "metadata": {}, "source": [ "Используя вентили X, H и CNOT, можно проводить эксперименты с первым в мире алгоритмом квантовых вычислений: алгоритм Дойча [dɔitʃ] является одним из наиболее распространенных квантовых алгоритмов, который определяет тип функции. В отличие от классических алгоритмов, алгоритм Дойча демонстрирует ускорение алгоритмов\n", "квантовых вычислений." ] }, { "cell_type": "code", "execution_count": 14, "id": "fc7fe56b-71b4-498c-955d-e5e56af8f08e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'11': 1024}\n" ] } ], "source": [ "from spinqit import get_basic_simulator, get_compiler, Circuit, BasicSimulatorConfig\n", "from spinqit import H, X, Rx, CNOT\n", "from math import pi\n", "\n", "# Write the program\n", "circ = Circuit()\n", "q = circ.allocateQubits(2)\n", "circ << (X, q[1])\n", "circ << (H, q[0])\n", "circ << (H, q[1])\n", "circ << (CNOT, (q[0], q[1]))\n", "circ << (H, q[0])\n", "circ << (H, q[1])\n", "\n", "# Choose the compiler and backend\n", "comp = get_compiler(\"native\")\n", "engine = get_basic_simulator()\n", "\n", "# Compile\n", "optimization_level = 0\n", "exe = comp.compile(circ, optimization_level)\n", "\n", "# Run\n", "config = BasicSimulatorConfig()\n", "config.configure_shots(1024)\n", "result = engine.execute(exe, config)\n", "\n", "print(result.counts)" ] }, { "cell_type": "code", "execution_count": null, "id": "c8fd21c4-ce4b-4d47-8bf6-ca241e994d1e", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "0c9946b4-0366-4129-ac6e-1e138309ee5f", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 5 }