Compare commits
6 Commits
7115e3ce7a
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 955a442c60 | |||
| 995f86831f | |||
| f742235573 | |||
| 050dde99f6 | |||
| b94b763cf1 | |||
| 672968bdfb |
@@ -121,6 +121,17 @@ dist:
|
||||
@just build
|
||||
@just build-documentation
|
||||
|
||||
# exports notebook to format: html, markdown, pdf, latex.
|
||||
export name format="pdf" theme="light":
|
||||
@{{PYTHON}} -m jupyter nbconvert \
|
||||
--allow-chromium-download \
|
||||
--HTMLExporter.theme={{theme}} \
|
||||
--TemplateExporter.exclude_input=false \
|
||||
--to {{format}} \
|
||||
--output-dir notes \
|
||||
--ouput "notebook-{{name}}.{{format}}" \
|
||||
notebooks/{{name}}.ipynb
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# TARGETS: run
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
+60
-31
@@ -49,7 +49,7 @@
|
||||
"u[8] = -0.7\n",
|
||||
"u[58] = 1j * sqrt(2);\n",
|
||||
"\n",
|
||||
"display_signal(u, 'Beispiel eines Vektors als Signal dargestellt');"
|
||||
"display_signal(u, 'Beispiel eines Vektors in $\\mathbb{C}^{100}$ als Signal über $\\{0,1,2,\\ldots,99\\}$ dargestellt');"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -101,26 +101,28 @@
|
||||
"Für $i\\in\\{0,1,\\ldots,n-1\\}$ ist die $i$-te von $\\mathcal{F}_{n}\\,u_{n,k}$\n",
|
||||
"\n",
|
||||
"$$\n",
|
||||
" \\begin{array}{rcl}\n",
|
||||
" (\\mathcal{F}_{n}\\,u_{n,k})_{i}\n",
|
||||
" = \\sum_{j=0}^{n-1}\n",
|
||||
" (\\mathcal{F}_{n})_{ij}\\,(u_{n,k})_{j}\n",
|
||||
" = \\sum_{j=0}^{n-1}\n",
|
||||
" &= &\\displaystyle\\sum_{j=0}^{n-1}\n",
|
||||
" (\\mathcal{F}_{n})_{ij}\\,(u_{n,k})_{j}\\\\\n",
|
||||
" &= &\\displaystyle\\sum_{j=0}^{n-1}\n",
|
||||
" \\tfrac{1}{\\sqrt{n}}\n",
|
||||
" \\exp(-\\imath\\tfrac{2\\pi\\,ij}{n})\n",
|
||||
" \\cdot\n",
|
||||
" \\tfrac{1}{\\sqrt{n}}\n",
|
||||
" \\exp(\\imath\\tfrac{2\\pi\\,kj}{n})\n",
|
||||
" = \\frac{1}{n}\\sum_{j=0}^{n-1}\n",
|
||||
" \\exp(\\imath\\tfrac{2\\pi\\,kj}{n})\\\\\n",
|
||||
" &= &\\frac{1}{n}\\displaystyle\\sum_{j=0}^{n-1}\n",
|
||||
" \\underbrace{\n",
|
||||
" \\exp(\\imath\\tfrac{2\\pi\\,(k-i)j}{n})\n",
|
||||
" }_{= r^{j}}\n",
|
||||
" }_{= r^{j}}\\\\\n",
|
||||
" \\end{array}\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"wobei $r \\colonequals \\exp(\\imath\\tfrac{2\\pi\\,(k-i)}{n})$.\n",
|
||||
"wobei $r := \\exp(\\imath\\tfrac{2\\pi\\,(k-i)}{n})$.\n",
|
||||
"Wir haben, dass\n",
|
||||
" $r = 1$\n",
|
||||
" $\\Leftrightarrow$\n",
|
||||
" $\\tfrac{k-i}{n} \\in \\Z$\n",
|
||||
" $\\tfrac{k-i}{n} \\in \\mathbb{Z}$\n",
|
||||
" $\\Leftrightarrow$\n",
|
||||
" $i = k$,\n",
|
||||
"da $0\\leq i,k \\leq n-1$.\n",
|
||||
@@ -130,23 +132,34 @@
|
||||
"Aus der o.s. Berechnung erhält man also\n",
|
||||
"\n",
|
||||
"$$\n",
|
||||
" \\begin{array}{rcl}\n",
|
||||
" (\\mathcal{F}_{n}\\,u_{n,k})_{i}\n",
|
||||
" = \\tfrac{1}{n}\\displaystyle\\sum_{j=0}^{n-1}r^{j}\n",
|
||||
" = \\tfrac{1}{n}\n",
|
||||
" \\begin{cases}\n",
|
||||
" &= &\\tfrac{1}{n}\\displaystyle\\sum_{j=0}^{n-1}r^{j}\\\\\n",
|
||||
" &= &\\tfrac{1}{n}\n",
|
||||
" \\left\\{\n",
|
||||
" \\begin{array}{lcl}\n",
|
||||
" \\displaystyle\\sum_{j=0}^{n-1}1 &: &i = k\\\\\n",
|
||||
" \\frac{1 - r^{n}}{1 - r} &: &\\text{sonst}\\\\\n",
|
||||
" \\end{cases}\n",
|
||||
" = \\tfrac{1}{n}\n",
|
||||
" \\begin{cases}\n",
|
||||
" \\dfrac{1 - r^{n}}{1 - r} &: &\\text{sonst}\\\\\n",
|
||||
" \\end{array}\n",
|
||||
" \\right.\\\\\n",
|
||||
" &= &\\tfrac{1}{n}\n",
|
||||
" \\left\\{\n",
|
||||
" \\begin{array}{lcl}\n",
|
||||
" n &: &i = k\\\\\n",
|
||||
" \\frac{1 - 1}{1 - r} &: &\\text{sonst}\\\\\n",
|
||||
" \\end{cases}\n",
|
||||
" = \\delta_{ik}.\n",
|
||||
" \\dfrac{1 - 1}{1 - r} &: &\\text{sonst}\\\\\n",
|
||||
" \\end{array}\n",
|
||||
" \\right.\\\\\n",
|
||||
" &= &\\left\\{\n",
|
||||
" \\begin{array}{lcl}\n",
|
||||
" 1 &: &i = k\\\\\n",
|
||||
" 0 &: &\\text{sonst}\\\\\n",
|
||||
" \\end{array}\n",
|
||||
" \\right.\\\\\n",
|
||||
" &= &\\delta_{ik}.\\\\\n",
|
||||
" \\end{array}\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"Darum $\n",
|
||||
" \\mathcal{F}_{n}\\,u_{n,k}\n",
|
||||
"Darum $\\mathcal{F}_{n}\\,u_{n,k}\n",
|
||||
" = \\left(\\begin{matrix}\n",
|
||||
" 0\\\\\n",
|
||||
" 0\\\\\n",
|
||||
@@ -163,8 +176,7 @@
|
||||
" \\\\\n",
|
||||
" \\\\\n",
|
||||
" \\end{matrix}\n",
|
||||
" = \\mathbf{e}_{k}\n",
|
||||
"$.\n"
|
||||
" = \\mathbf{e}_{k}$.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -199,16 +211,33 @@
|
||||
"# Anzeige der Lösung:\n",
|
||||
"display_signal(u_guess, 'Geschätztes Signal');\n",
|
||||
"\n",
|
||||
"# Verifikation von Lösung:\n",
|
||||
"print(dedent(\n",
|
||||
"# Verifizierung der Lösung:\n",
|
||||
"display_latex(\n",
|
||||
" f'''\n",
|
||||
" %error := ‖u_guess – u‖ / ‖u‖\n",
|
||||
" = ‖F_n · (u_guess – u)‖ / ‖F_n · u‖\n",
|
||||
" ... wieso?? [Stichwort: unitär]\n",
|
||||
" = ‖F_n · u_guess – F_n · u‖ / ‖F_n · u‖\n",
|
||||
" = {linalg.norm(F_n @ u_guess - F_mal_u)/linalg.norm(F_mal_u):.2%}\n",
|
||||
" $$\n",
|
||||
" \\\\begin{{array}}{{rcl}}\n",
|
||||
" \\\\%\\\\text{{error}}\n",
|
||||
" &\\colonequals\n",
|
||||
" &\\\\dfrac{{\\\\|u_{{\\\\text{{guess}}}} - u\\\\|}}{{\\\\|u\\\\|}}\\\\\\\\\n",
|
||||
" &=\n",
|
||||
" &\\\\dfrac{{\n",
|
||||
" \\\\|\\\\mathcal{{F}}_{{n}}\\\\,(u_{{\\\\text{{guess}}}} - u)\\\\|\n",
|
||||
" }}{{\n",
|
||||
" \\\\|\\\\mathcal{{F}}_{{n}}\\\\,u\\\\|\n",
|
||||
" }}\n",
|
||||
" \\\\quad\\\\text{{\\\\ldots wieso?? [Stichwort: unitär!]}}\\\\\\\\\n",
|
||||
" &= &\\\\dfrac{{\n",
|
||||
" \\\\|\\\\mathcal{{F}}_{{n}}\\\\,u_{{\\\\text{{guess}}}} - \\\\mathcal{{F}}_{{n}}\\\\,u\\\\|\n",
|
||||
" }}{{\n",
|
||||
" \\\\|\\\\mathcal{{F}}_{{n}}\\\\,u\\\\|\n",
|
||||
" }}\\\\\\\\\n",
|
||||
" &= &{linalg.norm(F_n @ u_guess - F_mal_u)/linalg.norm(F_mal_u):.2%}\n",
|
||||
" \\\\%\n",
|
||||
" \\\\\\\\\n",
|
||||
" \\\\end{{array}}\n",
|
||||
" $$\n",
|
||||
" '''\n",
|
||||
"));\n"
|
||||
");\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Vendored
+36
-3
@@ -6,14 +6,47 @@
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
from IPython.display import Latex;
|
||||
from IPython.display import display_latex;
|
||||
from IPython.display import display_png;
|
||||
from IPython.display import display_markdown;
|
||||
from IPython.display import display;
|
||||
from IPython.display import display_png;
|
||||
from IPython.display import display as display_text_ipython;
|
||||
from IPython.display import display_latex as display_latex_ipython;
|
||||
from IPython.display import display_markdown as display_md_ipython;
|
||||
import ipywidgets as widgets;
|
||||
# from array_to_latex import to_ltx as array_to_latex; # <- has issues
|
||||
from qiskit.visualization import array_to_latex;
|
||||
|
||||
from functools import wraps;
|
||||
from typing import Callable;
|
||||
from typing import TypeVar;
|
||||
|
||||
from src.thirdparty.misc import dedent;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# MODIFICATIONS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
T1 = TypeVar('T1');
|
||||
T2 = TypeVar('T2');
|
||||
|
||||
def display_with_dedent(pre_process: Callable[[str], T1] = lambda x: x):
|
||||
'''
|
||||
Returns a decorator that modifies string -> string methods
|
||||
'''
|
||||
def dec(method: Callable[[T1], T2]) -> Callable[[str], T2]:
|
||||
'''
|
||||
Performs method but dedents first.
|
||||
'''
|
||||
@wraps(method)
|
||||
def wrapped_method(text: str) -> T2:
|
||||
return method(pre_process(dedent(text)));
|
||||
return wrapped_method;
|
||||
|
||||
return dec;
|
||||
|
||||
display_latex = display_with_dedent(Latex)(display_latex_ipython);
|
||||
display_text = display_with_dedent()(display_text_ipython);
|
||||
display_markdown = display_with_dedent()(display_md_ipython);
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# EXPORTS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Reference in New Issue
Block a user