110 lines
9.2 KiB
Plaintext
110 lines
9.2 KiB
Plaintext
|
{
|
|||
|
"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+89OVEpiqKAiKiKqV1dABHVTAwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhLBcCEiEQwXIhL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r3MToFXhzz4ajD16b6x9Q+6HIxc3V2AHJsZZUN9wZ6vINTSqMe6YBcU85UIuwpFLNbAz4/oEut+PTm6Gq86Rq3HkQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILhQkQiGC5EJILT/6vYQ34e2Hcb691WVxUtTEX0RwyXKqRSqbAn0sfVZRC5BR4WEZEIhgsRiWC4EJEIhgsRiWC4EJEIhgsRiWC4EJEIhgsRiWC4EJEIhgsRiWC4EJEIhgsRiWC4EJEIhgsRiWC4EJEIhgsRiVApiqK4uoiaQlGAWR8BceddXYmcHu2AET2d09fSdXuxaf8J53QGwOFwwHKlCEa9Dmq1/PvunxrVwrxxTvphugBXoqtih0+5ugJZB+OcFy77jp2HtbDYOZ1dpdFoUFhsB2AX7yvmt0TxPlyJh0VEJILhQkQiGC5EJILhQkQ
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 337x248 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"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
|
|||
|
}
|