{ "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 }