Skip to content

Commit

Permalink
Merge branch 'main' of github.com:thosgood/qubit.guide
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-at-topos committed Mar 23, 2024
2 parents 88882a0 + 60d9090 commit 064f7ab
Show file tree
Hide file tree
Showing 33 changed files with 5,407 additions and 701 deletions.
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
29 changes: 7 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@ on:
paths-ignore:
- 'README.md'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
bookdown:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache Yarn packages
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -30,28 +26,17 @@ jobs:
- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Cache R packages
uses: actions/cache@v2
id: cache-r-packages
- name: Install R Dependencies
uses: r-lib/actions/setup-renv@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
cache-version: 1

- name: Setup Pandoc
uses: r-lib/actions/setup-pandoc@v2

- name: Setup TinyTeX
uses: r-lib/actions/setup-tinytex@v2

- name: Install R packages
if: steps.cache-r-packages.outputs.cache-hit != 'true'
run: |
R -e "install.packages('bookdown')"
R -e "install.packages('magick')"
R -e "install.packages('pdftools')"
- name: Build site
run: |
./build_book
Expand Down
29 changes: 7 additions & 22 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
bookdown:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache Yarn packages
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
sudo apt-get update
Expand All @@ -27,28 +23,17 @@ jobs:
- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Cache R packages
uses: actions/cache@v2
id: cache-r-packages
- name: Install R Dependencies
uses: r-lib/actions/setup-renv@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
cache-version: 1

- name: Setup Pandoc
uses: r-lib/actions/setup-pandoc@v2

- name: Setup TinyTeX
uses: r-lib/actions/setup-tinytex@v2

- name: Install R packages
if: steps.cache-r-packages.outputs.cache-hit != 'true'
run: |
R -e "install.packages('bookdown')"
R -e "install.packages('magick')"
R -e "install.packages('pdftools')"
- name: Build site
run: |
./build_book
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# qubit.guide

The online version of Introduction to Quantum Information Science by [Artur Ekert](https://www.arturekert.org/), [Tim Hosgood](https://thosgood.com/), [Alastair Kay](http://www.ma.rhul.ac.uk/akay/), and [Chiara Macchiavello](https://fisica.unipv.it/personale/Persona.php?ID=55).
The online version of *Introduction to Quantum Information Science* by [Artur Ekert](https://www.arturekert.org/), [Tim Hosgood](https://thosgood.com/), [Alastair Kay](http://www.ma.rhul.ac.uk/akay/), and [Chiara Macchiavello](https://fisica.unipv.it/personale/Persona.php?ID=55).

This work is licensed under [CC BY-NC-ND 4.0](cc-by-nc-nd).

Expand Down
14 changes: 0 additions & 14 deletions TO-DO.md

This file was deleted.

3 changes: 3 additions & 0 deletions _dependencies.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library(bookdown)
library(magick)
library(pdftools)
2 changes: 1 addition & 1 deletion _output.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ bookdown::pdf_book:
template: "latex/latex-template-a4.tex"
latex_engine: xelatex
keep_tex: yes
pandoc_args: ["--lua-filter=conditional-content.lua"]
pandoc_args: ["--lua-filter=conditional-content.lua"]
98 changes: 70 additions & 28 deletions index.Rmd

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions latex/latex-template-a4.tex
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
% Shortcuts and commands %
\definecolor{primary}{RGB}{177,98,78}
\definecolor{secondary}{RGB}{91,132,177}
\definecolor{tertiary}{RGB}{175,195,62}
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}

Expand Down
1 change: 1 addition & 0 deletions latex/latex-template-b5.tex
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
% Shortcuts and commands %
\definecolor{primary}{RGB}{177,98,78}
\definecolor{secondary}{RGB}{91,132,177}
\definecolor{tertiary}{RGB}{175,195,62}
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}

Expand Down
180 changes: 177 additions & 3 deletions latex/tikz2pdf.tex
Original file line number Diff line number Diff line change
@@ -1,14 +1,188 @@
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\usepackage{amsmath}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{quantikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{latex/tikz-3dplot-circleofsphere}
\usepackage{latex/tikz-3dplot-circleofsphere} % Bloch sphere diagrams
\usepackage{colortbl}
%% INSERT YOUR OWN CODE HERE

% General LaTeX
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
\providecommand{\NOT}{\texttt{NOT}}
\providecommand{\cNOT}{\texttt{c-NOT}}

% Colours
\definecolor{primary}{RGB}{177,98,78}
\definecolor{secondary}{RGB}{91,132,177}
\definecolor{tertiary}{RGB}{175,195,62}

% Quantikz settings
\tikzset{phase label/.append style={label position=above}}

% Error dot diagrams
\usetikzlibrary{calc}
\newcommand{\ErrorDotDiagram}[1]{% a list of coordinates (from (1,1) to (4,16)) for dots
\begin{scope}[scale=0.3]
\draw [fill=primary!60,thick] (0,0) rectangle (10,1);
\draw [fill=secondary!60,thick] (0,1) rectangle (10,4);
\draw [fill=primary!25,thick] (0,4) rectangle (10,5);
\draw [fill=secondary!25,thick] (0,5) rectangle (10,8);
\draw [fill=primary!25,thick] (0,8) rectangle (10,9);
\draw [fill=secondary!25,thick] (0,9) rectangle (10,12);
\draw [fill=primary!25,thick] (0,12) rectangle (10,13);
\draw [fill=secondary!25,thick] (0,13) rectangle (10,16);
\draw [dotted] (0,2) to (10,2);
\draw [dotted] (0,3) to (10,3);
\draw [dotted] (0,5) to (10,5);
\draw [dotted] (0,6) to (10,6);
\draw [dotted] (0,7) to (10,7);
\draw [thick] (0,8) to (10,8);
\draw [dotted] (0,9) to (10,9);
\draw [dotted] (0,10) to (10,10);
\draw [dotted] (0,11) to (10,11);
\draw [thick] (0,12) to (10,12);
\draw [dotted] (0,13) to (10,13);
\draw [dotted] (0,14) to (10,14);
\draw [dotted] (0,15) to (10,15);
%
\foreach \dot in {#1} % the list of grid coordinates for dots
\path let \p1 = \dot in node at ($(\x1*2.5,\y1)+(-1.25,-0.5)$) {$\bullet$};
\end{scope}
}

% Surface code diagrams
\tikzset{
data/.style={circle,draw,fill=primary,minimum size=0.6cm},
ancilla/.style={rectangle,draw,fill=gray!40,minimum size=0.6cm},
zwire/.style={thick},
xwire/.style={thick,dashed}
}

\newcommand{\plottoric}[1]{
\def\s{1.5cm}
%draw the vertices
\foreach \x in {0,...,#1} {
\foreach \y in {0,...,#1} {
\pgfmathtruncatemacro{\tot}{\x+\y};
\pgfmathtruncatemacro{\index}{\x+(#1+1)*\y};
\ifodd\index
\pgfmathtruncatemacro{\place}{(\index+1)/2};
\else
\pgfmathtruncatemacro{\place}{(\index+2)/2};
\fi
\ifodd\tot
\node [ancilla,alias=S\place] (a\x\y) at (\x*\s,-\y*\s) {};
\node [above right=0.01cm of a\x\y,inner sep=0] {$S_{\place}$};
\else
\node [data,alias=D\place] (a\x\y) at (\x*\s,-\y*\s) {};
\node [above right=0.12cm of a\x\y,inner sep=0] {$D_{\place}$};
\fi
}
}
\begin{scope}[on background layer]
%draw horizontal/vertical lines
\foreach \x in {0,...,#1}{
%vertical
\ifodd\x
\draw [xwire] (a\x0)--(a\x#1);
\else
\draw [zwire] (a\x0)--(a\x#1);
\fi
%horizontal
\ifodd\x
\draw [zwire] (a0\x)--(a#1\x);
\else
\draw [xwire] (a0\x)--(a#1\x);
\fi
}
\end{scope}
}

\newcommand{\plottoricnoancilla}[1]{
% \def\width{1} %there are \width+1 rows and columns
\def\s{1.5cm}
%draw the vertices
\foreach \x in {0,...,#1} {
\foreach \y in {0,...,#1} {
\pgfmathtruncatemacro{\tot}{\x+\y};
\pgfmathtruncatemacro{\index}{\x+(#1+1)*\y};
\ifodd\index
\pgfmathtruncatemacro{\place}{(\index+1)/2};
\else
\pgfmathtruncatemacro{\place}{(\index+2)/2};
\fi
\ifodd\tot
\coordinate [alias=S\place] (a\x\y) at (\x*\s,-\y*\s) {};
%\node [above right=0.01cm of a\x\y,inner sep=0] {$A_{\place}$};
\else
\node [data,alias=D\place] (a\x\y) at (\x*\s,-\y*\s) {};
%\node [above right=0.12cm of a\x\y,inner sep=0] {$D_{\place}$};
\fi
}
}
\begin{scope}[on background layer]
%draw horizontal/vertical lines
\foreach \x in {0,...,#1}{
%vertical
\ifodd\x
\draw [xwire] (a\x0)--(a\x#1);
\else
\draw [zwire] (a\x0)--(a\x#1);
\fi
%horizontal
\ifodd\x
\draw [zwire] (a0\x)--(a#1\x);
\else
\draw [xwire] (a0\x)--(a#1\x);
\fi
}
\end{scope}
}

\newcommand{\plotprimal}[1]{
% \def\width{1} %there are \width+1 rows and columns
\def\s{1.5cm}
%draw the vertices
\foreach \x in {0,...,#1} {
\foreach \y in {0,...,#1} {
\pgfmathtruncatemacro{\tot}{\x+\y};
\pgfmathtruncatemacro{\index}{\x+(#1+1)*\y};
\ifodd\index
\pgfmathtruncatemacro{\place}{(\index+1)/2};
\else
\pgfmathtruncatemacro{\place}{(\index+2)/2};
\fi
\ifodd\tot
\coordinate [alias=S\place] (a\x\y) at (\x*\s,-\y*\s) {};
%\node [above right=0.01cm of a\x\y,inner sep=0] {$A_{\place}$};
\else
\node [data,alias=D\place] (a\x\y) at (\x*\s,-\y*\s) {};
%\node [above right=0.12cm of a\x\y,inner sep=0] {$D_{\place}$};
\fi
}
}
\begin{scope}[on background layer]
%draw horizontal/vertical lines
\foreach \x in {0,...,#1}{
%vertical
\ifodd\x
\draw [white] (a\x0)--(a\x#1);
\else
\draw [zwire] (a\x0)--(a\x#1);
\fi
%horizontal
\ifodd\x
\draw [zwire] (a0\x)--(a#1\x);
\else
\draw [white] (a0\x)--(a#1\x);
\fi
}
\end{scope}
}

\begin{document}
\begin{preview}
%% TIKZ_CODE %%
Expand Down
Loading

0 comments on commit 064f7ab

Please sign in to comment.