Skip to content

Instantly share code, notes, and snippets.

@cgranade
Created January 29, 2020 19:03
Show Gist options
  • Save cgranade/c2e9f0e7f2128c6f4d6a467b4353836c to your computer and use it in GitHub Desktop.
Save cgranade/c2e9f0e7f2128c6f4d6a467b4353836c to your computer and use it in GitHub Desktop.
# Start from the IQ# base image. The definition for this image can be found at
# https://github.com/microsoft/iqsharp/blob/master/images/iqsharp-base/Dockerfile.
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.2001.2831
ENV IQSHARP_HOSTING_ENV=quantumcomputing-9690
# Make sure the contents of our repo are in ${HOME}.
# These steps are required for use on mybinder.org.
USER root
COPY . ${HOME}
RUN chown -R ${USER} ${HOME}
# Finish by dropping back to the notebook user.
USER ${USER}
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"ApplyZ\",\"CheckIfOperationsEqual\"]",
"text/html": [
"<ul><li>ApplyZ</li><li>CheckIfOperationsEqual</li></ul>"
],
"text/plain": [
"ApplyZ, CheckIfOperationsEqual"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"open Microsoft.Quantum.Arrays;\n",
"open Microsoft.Quantum.Diagnostics;\n",
"open Microsoft.Quantum.Math;\n",
"\n",
"operation ApplyZ(qubits : Qubit[]) : Unit is Adj + Ctl {\n",
" Z(Head(qubits));\n",
"}\n",
"\n",
"operation CheckIfOperationsEqual() : Unit {\n",
" AssertOperationsEqualReferenced(1,\n",
" ApplyZ,\n",
" Exp([PauliZ], PI() / 2.0, _)\n",
" );\n",
" Message(\"Operations are equal!\");\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Operations are equal!\n"
]
},
{
"data": {
"application/json": "{\"@type\":\"tuple\"}",
"text/plain": [
"()"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%simulate CheckIfOperationsEqual"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Q#",
"language": "qsharp",
"name": "iqsharp"
},
"language_info": {
"file_extension": ".qs",
"mimetype": "text/x-qsharp",
"name": "qsharp",
"version": "0.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment