📚 The CoCalc Library - books, templates and other resources
cocalc-examples / martinthoma-latex-examples / source-code / Pseudocode / Cholesky-Zerlegung / Animation / Animation.tex
132938 viewsLicense: OTHER
\documentclass[aspectratio=169,hyperref={pdfpagelabels=false}]{beamer}1\usepackage{lmodern}23\usepackage[utf8]{inputenc} % this is needed for german umlauts4\usepackage[ngerman]{babel} % this is needed for german umlauts5\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf67\usepackage{braket} % needed for \Set8\usepackage{algorithm,algpseudocode}910\usepackage{verbatim}11\usepackage{tikz}12\usetikzlibrary{arrows,shapes}1314% Define some styles for graphs15\tikzstyle{vertex}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt]16\tikzstyle{selected vertex} = [vertex, fill=red!24]17\tikzstyle{blue vertex} = [vertex, fill=blue!24]18\tikzstyle{edge} = [draw,thick,-]19\tikzstyle{weight} = [font=\small]20\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]21\tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20]2223% see http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html24%\usetheme{Frankfurt}25\usefonttheme{professionalfonts}2627% disables bottom navigation bar28\beamertemplatenavigationsymbolsempty2930% http://tex.stackexchange.com/questions/23727/converting-beamer-slides-to-animated-images31\setbeamertemplate{navigation symbols}{}%3233\newcommand{\alertline}{%34\usebeamercolor[fg]{normal text}%35\only{\usebeamercolor[fg]{alerted text}}}363738\begin{document}39\pgfdeclarelayer{background}40\pgfsetlayers{background,main}41\newcommand\hlight[1]{\tikz[overlay, remember picture,baseline=-\the\dimexpr\fontdimen22\textfont2\relax]\node[rectangle,fill=blue!50,rounded corners,fill opacity = 0.2,draw,thick,text opacity =1] {$#1$};}42\newcommand\tocalculate[1]{\tikz[overlay, remember picture,baseline=-\the\dimexpr\fontdimen22\textfont2\relax]\node[rectangle,fill=green!50,rounded corners,fill opacity = 0.2,draw,thick,text opacity =1] {$#1$};}4344\begin{frame}45\begin{minipage}[b]{0.30\linewidth}46\centering47\begin{align*}48A &= \begin{pmatrix}491 & 2 & 3\\502 & 8 & 14\\513 & 14 & 3452\end{pmatrix}\\53\alertline<1> L &= \alertline<1>\begin{pmatrix}540 & 0 & 0\\550 & 0 & 0\\560 & 0 & 057\end{pmatrix}\\58tmp &= 059\end{align*}60\end{minipage}61\hspace{0.5cm}62\begin{minipage}[b]{0.60\linewidth}63\centering64\begin{algorithm}[H]65\begin{algorithmic}66\Function{Cholesky}{$A \in \mathbb{R}^{n \times n}$}67\alertline<1>\State $L = \Set{0} \in \mathbb{R}^{n \times n}$ \Comment{Initialisiere $L$}\\6869\alertline<2>\alertline<4>\For{($k=1$; $\;k \leq n$; $\;k$++)}70\alertline<3>\State $L_{k,k} = \sqrt{A_{k,k} - \sum_{i=1}^{k-1} L_{k,i}^2}$71\For{($i=k+1$; $\;i \leq n$; $\;i$++)}72\State $L_{i,k} = \frac{A_{i,k} - \sum_{j=1}^{k-1} L_{i,j} \cdot L_{k,j}}{L_{k,k}}$73\EndFor74\EndFor75\alertline<5>\State \Return $L$76\EndFunction77\end{algorithmic}78\caption{Cholesky-Zerlegung}79\label{alg:seq1}80\end{algorithm}81\end{minipage}82\end{frame}83\begin{frame}84\begin{align*}85A &= \begin{pmatrix}86\hlight{1} & 2 & 3\\872 & 8 & 14\\883 & 14 & 3489\end{pmatrix}\\90L &= \begin{pmatrix}91\tocalculate{0} & 0 & 0\\920 & 0 & 0\\930 & 0 & 094\end{pmatrix}\\95tmp &= 096\end{align*}97\end{frame}98\begin{frame}99\begin{align*}100A &= \begin{pmatrix}1011 & 2 & 3\\1022 & 8 & 14\\1033 & 14 & 34104\end{pmatrix}\\105L &= \begin{pmatrix}106\tocalculate{1} & 0 & 0\\1070 & 0 & 0\\1080 & 0 & 0109\end{pmatrix}\\110tmp &= 0111\end{align*}112\end{frame}113%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%114% Calculate L_2,1115\begin{frame}116\begin{align*}117A &= \begin{pmatrix}1181 & 2 & 3\\119\hlight{2} & 8 & 14\\1203 & 14 & 34121\end{pmatrix}\\122L &= \begin{pmatrix}1231 & 0 & 0\\124\tocalculate{0} & 0 & 0\\1250 & 0 & 0126\end{pmatrix}\\127tmp &= 0128\end{align*}129\end{frame}130131\begin{frame}132\begin{align*}133A &= \begin{pmatrix}1341 & 2 & 3\\1352 & 8 & 14\\1363 & 14 & 34137\end{pmatrix}\\138L &= \begin{pmatrix}139\hlight{1} & 0 & 0\\140\tocalculate{2} & 0 & 0\\1410 & 0 & 0142\end{pmatrix}\\143tmp &= 0144\end{align*}145\end{frame}146147\begin{frame}148\begin{align*}149A &= \begin{pmatrix}1501 & 2 & 3\\1512 & 8 & 14\\1523 & 14 & 34153\end{pmatrix}\\154L &= \begin{pmatrix}1551 & 0 & 0\\156\tocalculate{2} & 0 & 0\\1570 & 0 & 0158\end{pmatrix}\\159tmp &= 0160\end{align*}161\end{frame}162%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%163% Calculate L_3,1164\begin{frame}165\begin{align*}166A &= \begin{pmatrix}1671 & 2 & 3\\1682 & 8 & 14\\169\hlight{3} & 14 & 34170\end{pmatrix}\\171L &= \begin{pmatrix}1721 & 0 & 0\\1732 & 0 & 0\\174\tocalculate{0} & 0 & 0175\end{pmatrix}\\176tmp &= 0177\end{align*}178\end{frame}179180\begin{frame}181\begin{align*}182A &= \begin{pmatrix}183\hlight{1} & 2 & 3\\1842 & 8 & 14\\1853 & 14 & 34186\end{pmatrix}\\187L &= \begin{pmatrix}1881 & 0 & 0\\1892 & 0 & 0\\190\tocalculate{3} & 0 & 0191\end{pmatrix}\\192tmp &= 0193\end{align*}194\end{frame}195196%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%197% Calculate L_2,2198\begin{frame}199\begin{align*}200A &= \begin{pmatrix}2011 & 2 & 3\\2022 & \hlight{8} & 14\\2033 & 14 & 34204\end{pmatrix}\\205L &= \begin{pmatrix}2061 & 0 & 0\\2072 & \tocalculate{0} & 0\\2083 & 0 & 0209\end{pmatrix}\\210tmp &= 0211\end{align*}212\end{frame}213214\begin{frame}215\begin{align*}216A &= \begin{pmatrix}2171 & 2 & 3\\2182 & 8 & 14\\2193 & 14 & 34220\end{pmatrix}\\221L &= \begin{pmatrix}2221 & 0 & 0\\223\hlight{2} & \tocalculate{8} & 0\\2243 & 0 & 0225\end{pmatrix}\\226tmp &= 0227\end{align*}228\end{frame}229230\begin{frame}231\begin{align*}232A &= \begin{pmatrix}2331 & 2 & 3\\2342 & 8 & 14\\2353 & 14 & 34236\end{pmatrix}\\237L &= \begin{pmatrix}2381 & 0 & 0\\2392 & \tocalculate{8} & 0\\2403 & 0 & 0241\end{pmatrix}\\242tmp &= \hlight{4}243\end{align*}244\end{frame}245246\begin{frame}247\begin{align*}248A &= \begin{pmatrix}2491 & 2 & 3\\2502 & 8 & 14\\2513 & 14 & 34252\end{pmatrix}\\253L &= \begin{pmatrix}2541 & 0 & 0\\2552 & \tocalculate{4} & 0\\2563 & 0 & 0257\end{pmatrix}\\258tmp &= 0259\end{align*}260\end{frame}261262263\begin{frame}264\begin{align*}265A &= \begin{pmatrix}2661 & 2 & 3\\2672 & 8 & 14\\2683 & 14 & 34269\end{pmatrix}\\270L &= \begin{pmatrix}2711 & 0 & 0\\2722 & \tocalculate{2} & 0\\2733 & 0 & 0274\end{pmatrix}\\275tmp &= 0276\end{align*}277\end{frame}278\end{document}279280281