Merge remote-tracking branch 'origin/master'
# Conflicts: # main.ipynb
This commit is contained in:
commit
183396208f
109
chapter1/Quantum gates.ipynb
Normal file
109
chapter1/Quantum gates.ipynb
Normal file
File diff suppressed because one or more lines are too long
BIN
dist/SpinQInterface_win_x86_64.dll
vendored
Normal file
BIN
dist/SpinQInterface_win_x86_64.dll
vendored
Normal file
Binary file not shown.
67
main.ipynb
Normal file
67
main.ipynb
Normal file
@ -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
|
||||||
|
}
|
2
run.bat
2
run.bat
@ -3,7 +3,7 @@ python -m venv .venv
|
|||||||
call .venv\Scripts\activate.bat
|
call .venv\Scripts\activate.bat
|
||||||
|
|
||||||
pip install -r requirements.txt
|
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
|
call jupyter lab
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user