Martin Thoma 11 år sedan
förälder
incheckning
a9a73319a3

+ 279 - 0
source-code/Pseudocode/Cholesky-Zerlegung/Animation/Animation.tex

@@ -0,0 +1,279 @@
+\documentclass[aspectratio=169,hyperref={pdfpagelabels=false}]{beamer}
+\usepackage{lmodern}
+ 
+\usepackage[utf8]{inputenc} % this is needed for german umlauts
+\usepackage[ngerman]{babel} % this is needed for german umlauts
+\usepackage[T1]{fontenc}    % this is needed for correct output of umlauts in pdf
+
+\usepackage{braket} % needed for \Set
+\usepackage{algorithm,algpseudocode}
+
+\usepackage{verbatim}
+\usepackage{tikz}
+\usetikzlibrary{arrows,shapes}
+ 
+% Define some styles for graphs
+\tikzstyle{vertex}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt]
+\tikzstyle{selected vertex} = [vertex, fill=red!24]
+\tikzstyle{blue vertex} = [vertex, fill=blue!24]
+\tikzstyle{edge} = [draw,thick,-]
+\tikzstyle{weight} = [font=\small]
+\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
+\tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20]
+ 
+% see http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
+%\usetheme{Frankfurt}
+\usefonttheme{professionalfonts}
+ 
+% disables bottom navigation bar
+\beamertemplatenavigationsymbolsempty
+ 
+% http://tex.stackexchange.com/questions/23727/converting-beamer-slides-to-animated-images
+\setbeamertemplate{navigation symbols}{}%
+
+\newcommand{\alertline}{%
+ \usebeamercolor[fg]{normal text}%
+ \only{\usebeamercolor[fg]{alerted text}}}
+
+
+\begin{document}
+\pgfdeclarelayer{background}
+\pgfsetlayers{background,main}
+\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$};}
+\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$};}
+ 
+\begin{frame}
+    \begin{minipage}[b]{0.30\linewidth}
+    \centering
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+       \alertline<1> L &= \alertline<1>\begin{pmatrix}
+            0 & 0 & 0\\
+            0 & 0 & 0\\
+            0 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+    \end{minipage}
+    \hspace{0.5cm}
+    \begin{minipage}[b]{0.60\linewidth}
+    \centering
+    \begin{algorithm}[H]
+        \begin{algorithmic}
+            \Function{Cholesky}{$A \in \mathbb{R}^{n \times n}$}
+                \alertline<1>\State $L = \Set{0} \in \mathbb{R}^{n \times n}$ \Comment{Initialisiere $L$}\\
+
+                \alertline<2>\alertline<4>\For{($k=1$; $\;k \leq n$; $\;k$++)}
+                    \alertline<3>\State $L_{k,k} = \sqrt{A_{k,k} - \sum_{i=1}^{k-1} L_{k,i}^2}$
+                    \For{($i=k+1$; $\;i \leq n$; $\;i$++)}
+                        \State $L_{i,k} = \frac{A_{i,k} - \sum_{j=1}^{k-1} L_{i,j} \cdot L_{k,j}}{L_{k,k}}$
+                    \EndFor
+                \EndFor
+                \alertline<5>\State \Return $L$
+            \EndFunction
+        \end{algorithmic}
+    \caption{Cholesky-Zerlegung}
+    \label{alg:seq1}
+    \end{algorithm}
+    \end{minipage}
+\end{frame}
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            \hlight{1} &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            \tocalculate{0} & 0 & 0\\
+            0 & 0 & 0\\
+            0 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            \tocalculate{1} & 0 & 0\\
+            0 & 0 & 0\\
+            0 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Calculate L_2,1
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            \hlight{2} &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            \tocalculate{0} & 0 & 0\\
+            0 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            \hlight{1} & 0 & 0\\
+            \tocalculate{2} & 0 & 0\\
+            0 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            \tocalculate{2} & 0 & 0\\
+            0 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Calculate L_3,1
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            \hlight{3} & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            2 & 0 & 0\\
+            \tocalculate{0} & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            \hlight{1} &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            2 & 0 & 0\\
+            \tocalculate{3} & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Calculate L_2,2
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  \hlight{8} & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            2 & \tocalculate{0} & 0\\
+            3 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            \hlight{2} & \tocalculate{8} & 0\\
+            3 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            2 & \tocalculate{8} & 0\\
+            3 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= \hlight{4}
+    \end{align*}
+\end{frame}
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            2 & \tocalculate{4} & 0\\
+            3 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+
+
+\begin{frame}
+    \begin{align*}
+        A &= \begin{pmatrix}
+            1 &  2 & 3\\
+            2 &  8 & 14\\
+            3 & 14 & 34
+        \end{pmatrix}\\
+        L &= \begin{pmatrix}
+            1 & 0 & 0\\
+            2 & \tocalculate{2} & 0\\
+            3 & 0 & 0
+        \end{pmatrix}\\
+        tmp &= 0
+    \end{align*}
+\end{frame}
+\end{document}

+ 35 - 0
source-code/Pseudocode/Cholesky-Zerlegung/Animation/Makefile

@@ -0,0 +1,35 @@
+SOURCE = Animation
+DELAY = 80
+DENSITY = 300
+WIDTH = 500
+
+make:
+	pdflatex $(SOURCE).tex -output-format=pdf
+	make clean
+
+clean:
+	rm -rf  $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
+
+gif:
+	pdfcrop $(SOURCE).pdf
+	convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
+	make clean
+
+png:
+	make
+	make svg
+	inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
+
+transparentGif:
+	convert $(SOURCE).pdf -transparent white result.gif
+	make clean
+
+svg:
+	make
+	#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
+	pdf2svg $(SOURCE).pdf $(SOURCE).svg
+	# Necessary, as pdf2svg does not always create valid svgs:
+	inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg
+	rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg
+	inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg
+	rm $(SOURCE)2.svg

+ 18 - 0
source-code/Pseudocode/Cholesky-Zerlegung/CholeskyZerlegung.py

@@ -0,0 +1,18 @@
+def getL(A):
+    n = len(A)
+    L = [[0 for i in range(n)] for j in range(n)]
+    print(L)
+    print("")
+ 
+    for k in range(n):
+        L[k][k] = (A[k][k] - sum([L[k][i]**2 for i in range(k)]))**0.5
+        for i in range(k+1, n):
+            L[i][k] = (A[i][k] 
+                        - sum([L[i][j]*L[k][j] for j in range(k)])) \
+                      / L[k][k]
+            print("L_%i%i = A%i%i - sum(L_...)/L_%i%i) = %i" % (i, k, i, k, k, k, L[i][k]))
+    return L
+
+A = [[1,2,3],[2,8,14],[3,14,34]]
+
+print getL(A)

+ 2 - 2
tikz/landtagswahlen-in-bayern/landtagswahlen-in-bayern.csv

@@ -1,8 +1,8 @@
 Wahltag,Wahlbeteiligung,CSU,SPD,FDP,GRÜNE,BP,FW,ÖDP,REP,NPD,KPD,GB/BHE,Sonstige
 1946-06-30,72.1,58.3,28.8,2.5,,,,,,,5.3,,WAV 5.1
 1946-12-01,75.7,52.3,28.6,5.7,,,,,,,6.1,,WAV 7.4
-1950-11-26,79.9,27.4,28.0,7.1,,17.9,,,,,1,9,12.3,WAV 2.8
-1954-11-28,82.4,38.0,28.1,7.2,,13.2,,,,,2,1,10.2,
+1950-11-26,79.9,27.4,28.0,7.1,,17.9,,,,,1.9,12.3,WAV 2.8
+1954-11-28,82.4,38.0,28.1,7.2,,13.2,,,,,2.1,10.2,
 1958-11-23,76.6,45.6,30.8,5.6,,8.1,,,,,,8.6,
 1962-11-25,76.5,47.5,35.3,5.9,,4.8,,,,,,GDP 5.1,
 1966-11-20,80.6,48.1,35.8,5.1,,3.4,,,,7.4,,,

BIN
tikz/landtagswahlen-in-bayern/landtagswahlen-in-bayern.png


+ 5 - 3
tikz/landtagswahlen-in-bayern/landtagswahlen-in-bayern.tex

@@ -30,9 +30,11 @@
           \addplot[blue, dashed, mark=triangle*] table [x=Wahltag, y=Wahlbeteiligung, col sep=comma] {landtagswahlen-in-bayern.csv};
           \addplot[black,mark=square*] table [x=Wahltag, y=CSU, col sep=comma] {landtagswahlen-in-bayern.csv};
           \addplot[red,mark=square*] table [x=Wahltag, y=SPD, col sep=comma] {landtagswahlen-in-bayern.csv};
-          \addplot[green,mark=square*] table [x=Wahltag, y=GRÜNE, col sep=comma] {landtagswahlen-in-bayern.csv};
-          \addplot[yellow,mark=square*] table [x=Wahltag, y=FDP, col sep=comma] {landtagswahlen-in-bayern.csv};
-          \legend{Wahlbeteiligung,CSU,SPD,Grüne,FDP}
+          \addplot[green,mark=x] table [x=Wahltag, y=GRÜNE, col sep=comma] {landtagswahlen-in-bayern.csv};
+          \addplot[yellow,mark=x] table [x=Wahltag, y=FDP, col sep=comma] {landtagswahlen-in-bayern.csv};
+          \addplot[blue,mark=x] table [x=Wahltag, y=BP, col sep=comma] {landtagswahlen-in-bayern.csv};
+          \addplot[orange,mark=x] table [x=Wahltag, y=FW, col sep=comma] {landtagswahlen-in-bayern.csv};
+          \legend{Wahlbeteiligung,CSU,SPD,Grüne,FDP,BP,FW}
     \end{axis}
 \end{tikzpicture}
 \end{document}