diff --git a/chapter1/Quantum gates.ipynb b/chapter1/Quantum gates.ipynb new file mode 100644 index 0000000..5182751 --- /dev/null +++ b/chapter1/Quantum gates.ipynb @@ -0,0 +1,109 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "60d947d2-c3f7-4d75-95e1-cf811094e9df", + "metadata": {}, + "outputs": [], + "source": [ + "SpinQit определяет 22 логических квантовых вентиля \n", + "(I, H, X, Y, Z, Rx, Ry, Rz, P, T, Td, S, Sd, CX/CNOT, CY, CZ, U, CP, SWAP, CCX, Ph, CSWAP)\n", + "и два специальных вентиля (MEASURE и BARRIER). \n", + "В частности, P — это вентили сдвига фазы, а Ph — это глобальные фазовые вентили." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "fbc7e45a-67df-4e4e-a8b3-a0df24f32b0d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'10': 512, '11': 512}\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAARcAAADSCAYAAABggYRnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAATHklEQVR4nO3deXhTVf4G8DdJk2Zpm662BVr2sggMMKNQwIKAMsqugrKMDDsijw4giziiLA7jT0AW9QeKoiMqAqOolH0RUIGiQAUsZSlQlu57m9A2yZ0/CsVKy9Z+k7S8n+fheUjuPTnfNO2bc+89OVEpiqKAiKiKqV1dABHVTAwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCE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Lo9quMJiG15eFo1543pi7pjHcTAuET+fuIjcgivw9dKjdURtPNA0HKt3HAYAmAw6TBn0MNKy82+Yhfvj0XOlh0ffHzmDQ/EXXfGUqg2nf3Bx5uh+WDBxMGKOJcDhcJTe/8p76xDQdTxy7uCS8Rdb9iOg63j8GHtSolSqIS6n52LMm2vx7lc/QK/TYmiPtpg8qDMGdG0NRQH+vWoHPvzuAADghaceQpCfFxZ88T0KrDdedubh0e1TKYqzrnFU7HxSOmxX5zTUrx0Etfr2Mi+vwIrUzJL5C2ZvIwJ9vcVqvB2KAvR72aUliKsVCPz/S87pa/Drq+5qfkp1oVapsGPJc64uQ4xbfCinbmjgXbVz1iVmIrpzXM+FiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIBMOFiEQwXIhIhFssc1mTtL8f+O2cq6uQ06mV8/rq0qYhNu6Pc16HTtamsfO+ytUV3GKBbiKqeXhYREQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQi/gedJ4aO+owYrQAAAABJRU5ErkJggg==", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from spinqit import get_basic_simulator, get_compiler, Circuit, BasicSimulatorConfig\n", + "from spinqit import H, CX, Rx, view\n", + "from math import pi\n", + "\n", + "# Write the program\n", + "circ = Circuit()\n", + "q = circ.allocateQubits(2)\n", + "circ << (Rx, q[0], pi)\n", + "circ << (H, q[1])\n", + "circ << (CX, (q[0], 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", + "#Draw\n", + "view.draw (exe)\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": "e2b9ac37-48c9-4140-a2c7-0716ef2f00e8", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2ff31459-0f9d-4e62-ab0c-fa47bd3170da", + "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 +} diff --git a/dist/SpinQInterface_win_x86_64.dll b/dist/SpinQInterface_win_x86_64.dll new file mode 100644 index 0000000..d2426a0 Binary files /dev/null and b/dist/SpinQInterface_win_x86_64.dll differ diff --git a/main.ipynb b/main.ipynb new file mode 100644 index 0000000..e07a4d6 --- /dev/null +++ b/main.ipynb @@ -0,0 +1,67 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "fc7fe56b-71b4-498c-955d-e5e56af8f08e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'10': 512, '11': 512}\n" + ] + } + ], + "source": [ + "from spinqit import get_basic_simulator, get_compiler, Circuit, BasicSimulatorConfig\n", + "from spinqit import H, CX, Rx\n", + "from math import pi\n", + "\n", + "# Write the program\n", + "circ = Circuit()\n", + "q = circ.allocateQubits(2)\n", + "circ << (Rx, q[0], pi)\n", + "circ << (H, q[1])\n", + "circ << (CX, (q[0], 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)" + ] + } + ], + "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 +} diff --git a/run.bat b/run.bat index 06ac7de..f4216ee 100644 --- a/run.bat +++ b/run.bat @@ -3,7 +3,7 @@ python -m venv .venv call .venv\Scripts\activate.bat pip install -r requirements.txt -copy .venv\SpinQInterface_win_x86_64.dll .venv\lib\site-packages\spinqit\ +copy dist\SpinQInterface_win_x86_64.dll .venv\lib\site-packages\spinqit\ call jupyter lab