<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Martin Thoma</title>
	<atom:link href="http://martin-thoma.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://martin-thoma.com</link>
	<description>A blog about Code, the Web and Cyberculture.</description>
	<lastBuildDate>Sat, 19 May 2012 11:45:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How do Bitmasks work?</title>
		<link>http://martin-thoma.com/how-do-bitmasks-work/</link>
		<comments>http://martin-thoma.com/how-do-bitmasks-work/#comments</comments>
		<pubDate>Fri, 18 May 2012 21:02:55 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[OS]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=17491</guid>
		<description><![CDATA[Contents1 What are Bitmasks?2 Bit operators3 Some examples4 See also What are Bitmasks? In computer science, a mask is data that is used for bitwise operations. Essentially it is a variable. They are very often used in C programs. Bit operators These are the bit operators: ~ Bitwise NOT (not to be confused with Logical [...]]]></description>
			<content:encoded><![CDATA[<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#What_are_Bitmasks">1 What are Bitmasks?</a></li><li><a href="#Bit_operators">2 Bit operators</a></li><li><a href="#Some_examples">3 Some examples</a></li><li><a href="#See_also">4 See also</a></li></ul></div>
<h2><span id="What_are_Bitmasks">What are Bitmasks?</span></h2>
<p>In computer science, a <a href="http://en.wikipedia.org/wiki/Mask_(computing)">mask</a> is data that is used for bitwise operations. Essentially it is a variable.</p>
<p>They are very often used in C programs.</p>
<h2><span id="Bit_operators">Bit operators</span></h2>
<p>These are the bit operators:</p>
<ul>
<li>~ Bitwise NOT (not to be confused with Logical NOT ‘!’)</li>
<li>&#038; Bitwise AND (not to be confused with Logical AND ‘&#038;&#038;’)</li>
<li>| Bitwise OR (again, not to be confused with Logical OR ‘||’)</li>
<li>^ Bitwise XOR</li>
<li>&lt;&lt; Bitwise left shift</li>
<li>&gt;&gt; Bitwise right shift</li>
</ul>
<p>This is how the operators work:</p>
<table style="border:1px solid black;" border="1">
<tr style="background-color:#ccff99">
<th>Bit A</th>
<th style="border-right:1px solid #000;">Bit B</th>
<th>A &#038; B</th>
<th>A | B</th>
<th style="border-right:1px solid #000;">A ^ B</th>
<th style="border-right:1px solid #000;">~A</th>
<th>A &lt;&lt; B</th>
<th>A &gt;&gt; B</th>
</tr>
<tr style="background-color:#ffffcc;">
<td>0</td>
<td style="border-right:1px solid #000;">0</td>
<td>0</td>
<td>0</td>
<td style="border-right:1px solid #000;">0</td>
<td style="border-right:1px solid #000;">1</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td style="border-right:1px solid #000;">1</td>
<td>0</td>
<td>1</td>
<td style="border-right:1px solid #000;">1</td>
<td style="border-right:1px solid #000;">1</td>
<td>0</td>
<td>0</td>
</tr>
<tr style="background-color:#ffffcc;">
<td>1</td>
<td style="border-right:1px solid #000;">0</td>
<td>0</td>
<td>1</td>
<td style="border-right:1px solid #000;">1</td>
<td style="border-right:1px solid #000;">0</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td style="border-right:1px solid #000;">1</td>
<td>1</td>
<td>1</td>
<td style="border-right:1px solid #000;">0</td>
<td style="border-right:1px solid #000;">0</td>
<td>2</td>
<td>0</td>
</tr>
</table>
<h2><span id="Some_examples">Some examples</span></h2>
<p>Lets say I have any variable named &#8220;variable&#8221; with 32 bit.</p>
<p>Get the last bit:</p>
<pre class="brush: cpp; title: ; notranslate">return variable &amp; 1;</pre>
<p>Get the first bit:</p>
<pre class="brush: cpp; title: ; notranslate">return variable &gt;&gt; 31;</pre>
<p>Get the bits 4 &#8211; 14 (11 bits):</p>
<pre class="brush: cpp; title: ; notranslate">return (variable  &gt;&gt; 4) &amp; ((1&lt;&lt;11) - 1);</pre>
<p>Getting the pow(2,11):</p>
<pre class="brush: cpp; title: ; notranslate">return 1&lt;&lt;11;</pre>
<h2><span id="See_also">See also</span></h2>
<ul>
<li><a href="http://stackoverflow.com/questions/231760/what-does-a-type-followed-by-t-underscore-t-represent/231807#231807">What does a type followed by _t (underscore-t) represent?</a>. Jonathan Leffler, Stackoverflow.</li>
<li><a href="http://stackoverflow.com/a/9602958/562769">Why does mode_t use 4 byte?</a>. Niklas B., Stackoverflow.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/how-do-bitmasks-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to visualize Graph algorithms with LaTeX</title>
		<link>http://martin-thoma.com/how-to-visualize-graph-algorithms-with-latex/</link>
		<comments>http://martin-thoma.com/how-to-visualize-graph-algorithms-with-latex/#comments</comments>
		<pubDate>Wed, 16 May 2012 11:16:29 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Tikz]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=24581</guid>
		<description><![CDATA[Tkiz is a very powerful TeX package. You can easily create visualizations of graphs and graph algorithms (if you have a template ). I recently found a great animation of Prim&#8217;s algorithm done by Kjell Magne Fauske. I&#8217;ve edited his source files to show an eulerian path. This is how it looks like: This animation [...]]]></description>
			<content:encoded><![CDATA[<p>Tkiz is a very powerful TeX package. You can easily create visualizations of graphs and graph algorithms (if you have a template <img src='http://martin-thoma.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).<br />
I recently found a great animation of Prim&#8217;s algorithm done by <a href="http://www.texample.net/tikz/examples/prims-algorithm/">Kjell Magne Fauske</a>. I&#8217;ve edited his source files to show an eulerian path. This is how it looks like:<br />
<div id="attachment_24611" class="wp-caption aligncenter" style="width: 522px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/tikz-animation.gif"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/tikz-animation.gif" alt="LaTeX (Tikz) animation of an eulerian path" title="LaTeX (Tikz) animation of an eulerian path" width="512" height="228" class="size-full wp-image-24611" /></a><p class="wp-caption-text">LaTeX (Tikz) animation of an eulerian path</p></div><br />
This animation was automatically created. See <a href='http://martin-thoma.com/wp-content/uploads/2012/05/LaTeX-example.zip'>Archive</a> and the intermediate <a href='http://martin-thoma.com/wp-content/uploads/2012/05/tikz-animation.pdf'>PDF</a>.</p>
<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#The_ideas">1 The ideas</a><ul><li><a href="#Draw_the_Graph">1.1 Draw the Graph</a></li><li><a href="#Animate">1.2 Animate</a></li><li><a href="#Status_quo">1.3 Status quo</a></li><li><a href="#Simplify_it">1.4 Simplify it</a></li></ul></li><li><a href="#The_whole_working_template">2 The whole, working template</a></li><li><a href="#Resources">3 Resources</a></li></ul></div>
<h2><span id="The_ideas">The ideas</span></h2>
<h3><span id="Draw_the_Graph">Draw the Graph</span></h3>
<p>If you want to visualize a graph algorithm, you should first try to get the image of the graph with Tikz.<br />
First include all packages / create the general structure of the document:</p>
<pre class="brush: plain; title: ; notranslate">\documentclass[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{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

% see http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
\usetheme{Frankfurt}
\usefonttheme{professionalfonts}

\begin{document}
\begin{frame}
	Your content will be here.
\end{frame}
\end{document}</pre>
<p>Simple graphs could look like this:</p>
<pre class="brush: plain; title: ; notranslate">\begin{figure}
	\begin{tikzpicture}[-&gt;,scale=1.8, auto,swap]
		% Draw the vertices.
		\node (a) at (0,0) {$a (this is text)$};
		\node (b) at (0,1) {$b$};
		\node (c) at (1,1) {$c$};
		\node (d) at (1,0) {$d$};
		\node (e) at (3,1) {$d$};

		% Connect vertices with edges and draw weights
		\path (a) edge node {} (b);
		\path (b) edge node {} (c);
		\path (c) edge node {} (d);
		\path (d) edge node {} (a);
	\end{tikzpicture}
\end{figure}</pre>
<p>You should get something similar to this:<br />
<div id="attachment_24691" class="wp-caption aligncenter" style="width: 310px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/simple-example-graph.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/simple-example-graph-300x105.png" alt="Simple example graph created with LaTeX and Tikz" title="Simple example graph created with LaTeX and Tikz" width="300" height="105" class="size-medium wp-image-24691" /></a><p class="wp-caption-text">Simple example graph created with LaTeX and Tikz</p></div></p>
<h3><span id="Animate">Animate</span></h3>
<p>Animations can be created with Tikz by working with layers. You don&#8217;t want to redraw the whole graph every time. Most of the time you want to overlay/underlay some parts of the graph. This can be achieved by declaring a new layer:</p>
<pre class="brush: plain; title: ; notranslate">\pgfdeclarelayer{NAME}</pre>
<p>Then you need to tell PGF which layers are to use in the next figure:</p>
<pre class="brush: plain; title: ; notranslate">\pgfsetlayers{LAYER LIST}</pre>
<p>The layer main should always be part of the list. Here is an example:</p>
<pre class="brush: plain; title: ; notranslate">\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}</pre>
<p>Now the magic begins. You consecutively add frames to the layer:</p>
<pre class="brush: plain; title: ; notranslate">	\begin{pgfonlayer}{background}
		\path&lt;2-&gt;[draw,line width=5pt,-,red!50] (a.center) edge node {} (b.center);
		\path&lt;10-&gt;[draw,line width=5pt,-,red!50] (b.center) edge node {} (d.center);
		\path&lt;12-&gt;[draw,line width=5pt,-,red!50] (d.center) edge node {} (e.center);
	\end{pgfonlayer}</pre>
<p>The number (2, 10 and 12 in this example) indicate the frame in which it should be added. This is the absolute frame, but 1 is the first frame of the figure environment!</p>
<h3><span id="Status_quo">Status quo</span></h3>
<pre class="brush: plain; title: ; notranslate">\documentclass[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{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

% see http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
\usetheme{Frankfurt}
\usefonttheme{professionalfonts}

\begin{document}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\begin{frame}
\begin{figure}
    \begin{tikzpicture}[-&gt;,scale=1.8, auto,swap]
        % Draw the vertices.
        \node (a) at (0,0) {$a (this is text)$};
        \node (b) at (0,1) {$b$};
        \node (c) at (1,1) {$c$};
        \node (d) at (1,0) {$d$};
		\node (e) at (3,1) {$d$};

        % Connect vertices with edges and draw weights
        \path (a) edge node {} (b);
        \path (b) edge node {} (c);
        \path (c) edge node {} (d);
        \path (d) edge node {} (a);

		\begin{pgfonlayer}{background}
			\path&lt;2-&gt;[draw,line width=5pt,-,red!50] (a.center) edge node {} (b.center);
			\path&lt;10-&gt;[draw,line width=5pt,-,red!50] (b.center) edge node {} (d.center);
			\path&lt;12-&gt;[draw,line width=5pt,-,red!50] (d.center) edge node {} (e.center);
		\end{pgfonlayer}
    \end{tikzpicture}
\end{figure}
\end{frame}
\end{document}</pre>
<h3><span id="Simplify_it">Simplify it</span></h3>
<p>You can make some definitions, e.g.:</p>
<pre class="brush: plain; title: ; notranslate">draw,line width=5pt,-,red!50</pre>
<p>can be replaced by</p>
<pre class="brush: plain; title: ; notranslate">\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]</pre>
<p>You can make loops:</p>
<pre class="brush: plain; title: ; notranslate">	% Draw the vertices.
	\foreach \pos / \identifier / \name in {{(0,0)/a/a (this is text)},
		{(0,1)/b/b}, {(1,1)/c/c}, {(1,0)/d/d}, {(3,1)/e/d}}
		\node (\identifier) at \pos {$\name$};</pre>
<h2><span id="The_whole_working_template">The whole, working template</span></h2>
<pre class="brush: plain; title: ; notranslate">\documentclass[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{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}{}%

\begin{document}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\begin{frame}
	\begin{figure}
		\begin{tikzpicture}[-&gt;,scale=1.8, auto,swap]
			% Draw the vertices. First you define a list.
			\foreach \pos/\name in {{(0,0)/a}, {(0,2)/b}, {(1,2)/c},
				                    {(1,0)/d}, {(2,1)/e}, {(3,1)/f},
									{(4,2)/g}, {(5,2)/h}, {(4,0)/i},
									{(5,0)/j}}
				\node[vertex] (\name) at \pos {$\name$};

			% Connect vertices with edges and draw weights
			\foreach \source/ \dest /\pos in {a/b/, b/c/, c/d/, d/a/,
										c/e/bend left, d/e/, e/c/,
										e/f/, f/g/, f/i/,
										g/f/bend right, i/f/bend left,
										g/h/, h/j/, j/i/, i/g/}
				\path (\source) edge [\pos] node {} (\dest);

			% Start animating the edge selection.
			% For convenience we use a background layer to
			% highlight edges. This way we don't have to worry about
			% the highlighting covering weight labels.
			\begin{pgfonlayer}{background}
				\foreach \source / \dest / \fr / \pos in {d/a/1/,
						a/b/2/, b/c/3/, c/d/4/, d/e/5/, e/c/6/,
						c/e/7/bend left, e/f/8/, f/g/9/,
						g/f/10/bend right, f/i/11/, i/g/12/, g/h/13/,
						h/j/14/, j/i/15/, i/f/16/bend left}
				    \path&lt;\fr-&gt;[selected edge] (\source.center) edge
										[\pos] node {} (\dest.center);
			\end{pgfonlayer}
		\end{tikzpicture}
	\end{figure}
	Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
	sed diam nonumy eirmod tempor invidunt ut labore et dolore
	magna aliquyam erat, sed diam voluptua. At vero eos et
	accusam et.
\end{frame}
\end{document}</pre>
<h2><span id="Resources">Resources</span></h2>
<ul>
<li><a href="http://paws.wcu.edu/tsfoguel/tikzpgfmanual.pdf">TikZ and pgf: Manual for version 1.18</a></li>
<li><a href="http://www.texample.net/tikz/examples/">TeXamples.net</a>: Great page with many Tikz-Examples</li>
<li><a href="http://www.tex.ac.uk/CTAN/macros/latex/contrib/beamer/doc/beameruserguide.pdf">The beamer class</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/how-to-visualize-graph-algorithms-with-latex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to create UML class diagrams</title>
		<link>http://martin-thoma.com/how-to-create-uml-class-diagrams/</link>
		<comments>http://martin-thoma.com/how-to-create-uml-class-diagrams/#comments</comments>
		<pubDate>Sun, 06 May 2012 18:38:01 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[My bits and bytes]]></category>
		<category><![CDATA[Dia]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[MetaUML]]></category>
		<category><![CDATA[UML]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=24161</guid>
		<description><![CDATA[Contents1 Dia2 LaTeX2.1 MetaUML3 See also Dia Creating UML diagrams with Dia works like a charm! It provides some default tools. You should simply try it. Dia is a free tool. Take a look at these screenshots: LaTeX I only know MetaUML for creating class diagrams entirely in LaTeX. Does anybody know something different? Of [...]]]></description>
			<content:encoded><![CDATA[<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#Dia">1 Dia</a></li><li><a href="#LaTeX">2 LaTeX</a><ul><li><a href="#MetaUML">2.1 MetaUML</a></li></ul></li><li><a href="#See_also">3 See also</a></li></ul></div>
<h2><span id="Dia">Dia</span></h2>
<p>Creating UML diagrams with Dia works like a charm! It provides some default tools. You should simply try it. Dia is a free tool.</p>
<p>Take a look at these screenshots:<br />
<div id="attachment_24211" class="wp-caption aligncenter" style="width: 241px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/dia-create-class.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/dia-create-class.png" alt="Create a class for a class diagram in Dia" title="Create a class for a class diagram in Dia" width="231" height="611" class="size-full wp-image-24211" /></a><p class="wp-caption-text">Create a class for a class diagram in Dia</p></div></p>
<div id="attachment_24221" class="wp-caption aligncenter" style="width: 686px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/dia-class-properties.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/dia-class-properties.png" alt="Edit class properties in Dia" title="Edit class properties in Dia" width="676" height="589" class="size-full wp-image-24221" /></a><p class="wp-caption-text">Edit class properties in Dia</p></div>
<div id="attachment_24231" class="wp-caption aligncenter" style="width: 464px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/dia-association.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/dia-association.png" alt="Customizing associations in Dia" title="Customizing associations in Dia" width="454" height="447" class="size-full wp-image-24231" /></a><p class="wp-caption-text">Customizing associations in Dia - adding multiplicities is so much easier in Dia than in MetaUML!</p></div>
<div id="attachment_24251" class="wp-caption aligncenter" style="width: 529px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/Dia-ClassDiagram.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/Dia-ClassDiagram.png" alt="A quick example for a class diagram created with Dia" title="A quick example for a class diagram created with Dia" width="519" height="104" class="size-full wp-image-24251" /></a><p class="wp-caption-text">A quick example for a class diagram created with Dia</p></div>
<h2><span id="LaTeX">LaTeX</span></h2>
<p>I only know MetaUML for creating class diagrams entirely in LaTeX. Does anybody know something different? </p>
<p>Of course, you can include a diagram created with Dia:</p>
<ol>
<li>Export the diagram as PNG (antialized)</li>
<li>Add something like that to your tex-file: \includegraphics[width=180mm]{myDiagramm.png}</li>
</ol>
<h3><span id="MetaUML">MetaUML</span></h3>
<p>A MetaUML class diagram looks like that in code (saved as myMetaDiagram.mp):</p>
<pre class="brush: plain; title: ; notranslate">input metauml;
beginfig(1);
	Class.World(&quot;World&quot;)
		   (&quot;-age: int&quot;,
			&quot;#ressources: List&quot;)
		   (&quot;+sayHello(): void&quot;);

	Class.NoHuman(&quot;Human&quot;)
		   (&quot;-birthday: Date&quot;,
			&quot;-nickname: String&quot;,
			&quot;-secret: String&quot;)
		   (&quot;+code(language: Language): Program&quot;);

	leftToRight(50)(World, NoHuman);
	drawObjects(World, NoHuman);

	link(aggregation)(NoHuman.w -- World.e);
	item(iAssoc)(&quot;1&quot;)(obj.n     = .2[World.e,NoHuman.w]);
	item(iAssoc)(&quot;has &gt;&quot;)(obj.n = .5[World.e,NoHuman.w]);
	item(iAssoc)(&quot;0..*&quot;)(obj.n  = .8[World.e,NoHuman.w]);

endfig;
end</pre>
<p>You have to execute mpost before you can compile LaTeX. A working example is in this <a href='http://martin-thoma.com/wp-content/uploads/2012/05/UML.zip'>UML Archive</a>.</p>
<p>It looks like that in your generated PDF file:<br />
<div id="attachment_24271" class="wp-caption aligncenter" style="width: 686px"><a href="http://martin-thoma.com/wp-content/uploads/2012/05/MetaUML-class-diagram.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/05/MetaUML-class-diagram.png" alt="MetaUML class diagram" title="MetaUML class diagram" width="676" height="161" class="size-full wp-image-24271" /></a><p class="wp-caption-text">MetaUML class diagram</p></div></p>
<h2><span id="See_also">See also</span></h2>
<ul>
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Class_diagram">Class diagram</a>, <a href="http://en.wikipedia.org/wiki/Dia_(software)">Dia</a></li>
<li>Dia:  <a href="http://www.wspiegel.de/infogk12/oops/dia_einf.html#py16_2">Dia und UML</a></li>
<li><a href="http://ftp.fernuni-hagen.de/ftp-dir/pub/mirrors/www.ctan.org/graphics/metapost/contrib/macros/metauml/doc/metauml_manual_0.2.5.pdf">MetaUML: Tutorial, Reference and Test Suite</a></li>
<li>Freies Magazin, Mai 2012: <a href="http://www.freiesmagazin.de/freiesMagazin-2012-05">Astah – Kurzvorstellung des UML-Programms</a> (German)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/how-to-create-uml-class-diagrams/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Code Jam 2012 – Round 1C 2012</title>
		<link>http://martin-thoma.com/google-code-jam-2012-round-1c-2012/</link>
		<comments>http://martin-thoma.com/google-code-jam-2012-round-1c-2012/#comments</comments>
		<pubDate>Sun, 06 May 2012 12:03:54 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Code Jam]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=24081</guid>
		<description><![CDATA[4230 tried the first problem, but only 3189 people are listed in the scoreboard. Problem 1 (Diamond Inheritance): Small Set: 3077/4230 users (73%) Large Set: 2387/3044 users (78%) Problem 2 (Out of Gas): Small Set: 471/766 users (61%) Large Set: 73/253 users (29%) Problem 3 (Box Factory): Small Set: 1071/1810 users (59%) Large Set: 308/788 [...]]]></description>
			<content:encoded><![CDATA[<p>4230 tried the first problem, but only 3189 people are listed in the <a href="http://code.google.com/codejam/contest/1781488/scoreboard?c=1781488">scoreboard</a>.</p>
<ul>
<li>Problem 1 (<a href="http://code.google.com/codejam/contest/1781488/dashboard#s=p0">Diamond Inheritance</a>):
<ul>
<li>Small Set: 3077/4230 users (73%)</li>
<li>Large Set: 2387/3044 users (78%)</li>
</ul>
</li>
<li>Problem 2 (<a href="http://code.google.com/codejam/contest/1781488/dashboard#s=p1">Out of Gas</a>):
<ul>
<li>Small Set: 471/766 users (61%)</li>
<li>Large Set: 73/253 users (29%)</li>
</ul>
</li>
<li>Problem 3 (<a href="http://code.google.com/codejam/contest/1781488/dashboard#s=p2">Box Factory</a>):
<ul>
<li>Small Set: 1071/1810 users (59%)</li>
<li>Large Set: 308/788 users (39%)</li>
</ul>
</li>
</ul>
<h2>Diamond Inheritance</h2>
<pre class="brush: python; title: ; notranslate">#!/usr/bin/python
# -*- coding: utf-8 -*-

import psyco
psyco.full()

testcases = input()

def line2intlist(line):
	list = line.split(' ')
	numbers = [ int(x) for x in list ]
	return numbers

def getAnswer(classDict, N):
	for startPoint in xrange(1, N):
		reachable = [startPoint]
		justAppended = [startPoint]
		while len(justAppended) &gt; 0:
			newJustAppended = []
			for node in justAppended:
				for new in classDict[node]:
					if new in reachable:
						return &quot;Yes&quot;
					else:
						newJustAppended.append(new)
						reachable.append(new)
			justAppended = newJustAppended
	return &quot;No&quot;

for i in xrange(0, testcases):
	N = input()
	classDict = {}
	for classNr in xrange(1, N+1):
		liste = line2intlist(raw_input())
		classDict[classNr] = liste[1:]
	print(&quot;Case #%i: %s&quot; % (i+1, getAnswer(classDict, N)))</pre>
<h2>See also</h2>
<ul>
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Google_Code_Jam">Google Code Jam</a></li>
<li><a href="http://www.go-hero.net/jam/12/">Google Code Jam Statistics</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/google-code-jam-2012-round-1c-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Code Jam 2012 – Round 1B 2012</title>
		<link>http://martin-thoma.com/google-code-jam-2012-round-1b-2012/</link>
		<comments>http://martin-thoma.com/google-code-jam-2012-round-1b-2012/#comments</comments>
		<pubDate>Sat, 05 May 2012 19:20:45 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Code Jam]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=23971</guid>
		<description><![CDATA[5614 tried the first problem, but only 3281 people are listed in the scoreboard. So quite a lot tried to solve a problem, but couldn&#8217;t even solve one. I think these problems were much harder than the ones from Round 1A 2012. Problem 1 (Safety in Numbers): Small Set: 2695/5614 users (48%) Large Set: 2016/2686 [...]]]></description>
			<content:encoded><![CDATA[<p>5614 tried the first problem, but only 3281 people are listed in the scoreboard. So quite a lot tried to solve a problem, but couldn&#8217;t even solve one. I think these problems were much harder than the ones from <a href="http://martin-thoma.com/google-code-jam-2012-round-1a-2012/" title="Google Code Jam 2012 – Round 1A 2012">Round 1A 2012</a>.</p>
<ul>
<li>Problem 1 (<a href="http://code.google.com/codejam/contest/1836486/dashboard#s=p0">Safety in Numbers</a>):
<ul>
<li>Small Set: 2695/5614 users (48%)</li>
<li>Large Set: 2016/2686 users (75%)</li>
</ul>
</li>
<li>Problem 2 (<a href="http://code.google.com/codejam/contest/1836486/dashboard#s=p1">Tide Goes In, Tide Goes Out</a>):
<ul>
<li>Small Set: 684/894 users (77%)</li>
<li>Large Set: 620/671 users (92%)</li>
</ul>
</li>
<li>Problem 3 (<a href="http://code.google.com/codejam/contest/1836486/dashboard#s=p2">Equal Sums</a>):
<ul>
<li>Small Set: 2261/2534 users (89%)</li>
<li>Large Set: 149/854 users (17%)</li>
</ul>
</li>
</ul>
<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#Safety_in_Numbers">1 Safety in Numbers</a></li><li><a href="#Tide_Goes_In_Tide_Goes_Out">2 Tide Goes In, Tide Goes Out</a></li><li><a href="#Equal_Sums">3 Equal Sums</a></li><li><a href="#See_also">4 See also</a></li></ul></div>
<h2><span id="Safety_in_Numbers">Safety in Numbers</span></h2>
<p>I tried this approach:<br />
X is the sum of all points given by judges. The visitors have an equal amount of points to give.<br />
\(P_i\) is the number of total points of contestant i.<br />
\(J_i\) is the number of points of contestant i by the judges.<br />
\(V_i\) is the percentage of the visitors points contestant i gets.</p>
<p>So: \(P_i = J_i + V_i * X\)</p>
<p>You don&#8217;t know \(V_i\) and \(P_i\). You have to get the minimal value of \(V_i\) to guarantee that contestant \(i\) will not to be eliminated. So you have to create some kind of &#8220;worst case&#8221; for contestant i, if he gets \(V_i \cdot X\) visitor-points. The worst case is that the minimum of all remaining visitors is as high as possible. So if you think of them as players, they will always try to get a equal number of points.</p>
<p>If they can get an equal number of points, you can make these (in)equations:<br />
\(average = (X &#8211; p_i)/(N-1)\)<br />
\(p_i + V_i \cdot X \geq avg + \frac{1-V_i}{N-1} \cdot X\)<br />
\(V_i \cdot X &#8211; \frac{1-V_i}{N-1}  \cdot X \geq avg &#8211; p_i\)<br />
\(V_i X (N-1) &#8211; (1-V_i) \cdot X \geq (N-1) \cdot (avg &#8211; p_i)\)<br />
\(V_i X (N-1) &#8211; X +V_i \cdot X \geq (N-1) \cdot (avg &#8211; p_i)\)<br />
\(V_i X (N-1) +V_i \cdot X \geq (N-1) \cdot (avg &#8211; p_i) + X\)<br />
\(V_i \geq (N-1) \cdot ((avg &#8211; p_i) + X)/(X (N-1) +X)\)<br />
\(V_i \geq (N-1) \cdot ((avg &#8211; p_i) + X)/(X ((N-1) +1))\)<br />
\(V_i \geq \frac{N-1}{X \cdot N} \cdot (avg &#8211; p_i + X)\)</p>
<p>Unfortunately, its possible that the other players can&#8217;t get an equal number of points. So this approach is useless in this case.</p>
<p>Here is an approach with an approximation, which also works for the large input set.</p>
<pre class="brush: cpp; title: ; notranslate">#include &lt;iostream&gt;
#include &lt;cstdio&gt;
using namespace std;

int main() {

	int testcases, N, sum;
	int s[1011];

	cin &gt;&gt; testcases;

	for (int caseNr = 1; caseNr &lt;= testcases; caseNr++) {
		cin &gt;&gt; N;

		/** the sum of all points of all contestants*/
		sum = 0;

    	for (int i = 0; i &lt; N; i++) {
			cin &gt;&gt; s[i];
			sum += s[i];
		}

		printf(&quot;Case #%d:&quot;, caseNr);

		for (int contestant = 0; contestant &lt; N; contestant++) {
			// approximate the minimum for each contestant
			double low = 0, high = 1;

			// increase the accuracy 100 times
			for (int j = 0; j &lt; 100; j++) {
				double mid = (low + high) / 2;
				double me = s[contestant] + mid * sum;
				double remaining = 1 - mid;

				for (int k = 0; k &lt; N &amp;&amp; remaining &gt; 0; k++) {
					if (k != contestant &amp;&amp; s[k] &lt; me) {
						// the contestant k needs at least
						// this part of all audience votes
						remaining -= (me - s[k]) / sum;
					}
				}

				if (remaining &gt; 0) {
					low = mid;
				} else {
					high = mid;
				}
			}
			printf(&quot; %.6lf&quot;, low * 100);
		}

		printf(&quot;\n&quot;);
	}
}</pre>
<h2><span id="Tide_Goes_In_Tide_Goes_Out">Tide Goes In, Tide Goes Out</span></h2>
<p>This one could be solved with Graphs. You calculate one Graph, where every node is one cell. Every cell / node is connected to adjacent cells. Every cell has a value which is the time when you can enter them.</p>
<p>After you&#8217;ve created the graph, you can make something like that:</p>
<pre class="brush: python; title: ; notranslate">
graph = createGraph(floorHeight, ceilingHeight)
endReached = False
nodesReached = []
while (not endReached):
    tmp = getMinimumAdjacentNode(graph, nodesReached)
    nodesReached.append(tmp)
return maxTime(nodesReached)
</pre>
<h2><span id="Equal_Sums">Equal Sums</span></h2>
<p>A trivial solution for the small one is to try every combination. You might want to take a look at Pythonss <a href="http://docs.python.org/library/itertools.html#itertools.combinations">itertools.combinations()</a>.</p>
<h2><span id="See_also">See also</span></h2>
<ul>
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Google_Code_Jam">Google Code Jam</a></li>
<li><a href="http://www.go-hero.net/jam/12/">Google Code Jam Statistics</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/google-code-jam-2012-round-1b-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to print Source Code with LaTeX</title>
		<link>http://martin-thoma.com/how-to-print-source-code-with-latex/</link>
		<comments>http://martin-thoma.com/how-to-print-source-code-with-latex/#comments</comments>
		<pubDate>Sun, 29 Apr 2012 10:04:32 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[LaTeX]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=23541</guid>
		<description><![CDATA[I often need to print source code. Some years ago for a German competition called &#8220;Bundeswettbewerb Informatik&#8221;, now for projects at my university. If you use LaTeX, you can simply include the source code into your document! Here are three examples with listings and minted. I&#8217;ve also included example PDF files. Contents1 listings1.1 Minimal example1.2 [...]]]></description>
			<content:encoded><![CDATA[<p>I often need to print source code. Some years ago for a German competition called &#8220;Bundeswettbewerb Informatik&#8221;, now for projects at my university. If you use LaTeX, you can simply include the source code into your document! Here are three examples with listings and minted. I&#8217;ve also included example PDF files.</p>
<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#listings">1 listings</a><ul><li><a href="#Minimal_example">1.1 Minimal example</a></li><li><a href="#My_Template">1.2 My Template</a></li><li><a href="#Supported_Languages">1.3 Supported Languages</a></li></ul></li><li><a href="#minted">2 minted</a><ul><li><a href="#Example">2.1 Example</a></li></ul></li><li><a href="#Material">3 Material</a></li><li><a href="#See_also">4 See also</a></li></ul></div>
<h2><span id="listings">listings</span></h2>
<h3><span id="Minimal_example">Minimal example</span></h3>
<p><div id="attachment_23851" class="wp-caption aligncenter" style="width: 600px"><a href="http://martin-thoma.com/wp-content/uploads/2012/04/latex-java-source-listings.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/04/latex-java-source-listings.png" alt="LaTeX Java Source Code: listings" title="LaTeX Java Source Code: listings" width="590" height="185" class="size-full wp-image-23851" /></a><p class="wp-caption-text">LaTeX Java Source Code: listings</p></div><br />
Here is an minimal example how you could print Source Code with LaTeX:<br />
<span id="more-23541"></span></p>
<pre class="brush: plain; title: ; notranslate">\documentclass[a4paper,12pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\usepackage[utf8]{inputenc} % this is needed for german umlauts
\usepackage[ngerman]{babel} % this is needed for german umlauts
% this is needed for correct output of umlauts in pdf
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry} %layout
\usepackage{listings} % needed for the inclusion of source code

% this is needed for forms and links within the text
\usepackage{hyperref}  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE DOCUMENT BEGINS                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
	\lstinputlisting[language=Java]{Othello.java}
\end{document}</pre>
<h3><span id="My_Template">My Template</span></h3>
<p>If you want to customize a little bit more and if you want to get highlighted (colorized) source code, you could use the following template. It looks like this as a <a href='http://martin-thoma.com/wp-content/uploads/2012/04/LaTeX-Source-Code.pdf'>PDF-file</a>.</p>
<pre class="brush: plain; title: ; notranslate">\documentclass[a4paper,12pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\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[margin=2.5cm]{geometry} %layout
\usepackage{listings} % needed for the inclusion of source code

% the following is needed for syntax highlighting
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{ %
  language=Java,                  % the language of the code
  basicstyle=\footnotesize,       % the size of the fonts that are used for the code
  numbers=left,                   % where to put the line-numbers
  numberstyle=\tiny\color{gray},  % the style that is used for the line-numbers
  stepnumber=1,                   % the step between two line-numbers. If it's 1, each line
                                  % will be numbered
  numbersep=5pt,                  % how far the line-numbers are from the code
  backgroundcolor=\color{white},  % choose the background color. You must add \usepackage{color}
  showspaces=false,               % show spaces adding particular underscores
  showstringspaces=false,         % underline spaces within strings
  showtabs=false,                 % show tabs within strings adding particular underscores
  frame=single,                   % adds a frame around the code
  rulecolor=\color{black},        % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. commens (green here))
  tabsize=4,                      % sets default tabsize to 2 spaces
  captionpos=b,                   % sets the caption-position to bottom
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  title=\lstname,                 % show the filename of files included with \lstinputlisting;
                                  % also try caption instead of title
  keywordstyle=\color{blue},          % keyword style
  commentstyle=\color{dkgreen},       % comment style
  stringstyle=\color{mauve},         % string literal style
  escapeinside={\%*}{*)},            % if you want to add a comment within your code
  morekeywords={*,...}               % if you want to add more keywords to the set
}

% this is needed for forms and links within the text
\usepackage{hyperref}  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Variablen                                 						 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\authorName}{Martin Thoma}
\newcommand{\tags}{\authorName, my, tags}
\title{This is the title}
\author{\authorName}
\date{\today}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PDF Meta information                                 				 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\hypersetup{
  pdfauthor   = {\authorName},
  pdfkeywords = {\tags},
  pdftitle    = {This is the title}
} 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE DOCUMENT BEGINS             	                              	 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
	\lstinputlisting[language=Java]{Othello.java}
\end{document}</pre>
<h3><span id="Supported_Languages">Supported Languages</span></h3>
<p>The LaTeX listings package provides quite a lot of language and dialects. Each bold dialect is the default dialect:</p>
<p>First the interesting ones:</p>
<ul>
<li>Assembler (Motorola68k, x86masm)</li>
<li>bash</li>
<li>C (<strong>ANSI</strong>, Handel, Objective, Sharp)</li>
<li>C++ (ANSI, GNU, <strong>ISO</strong>, Visual)</li>
<li>Java (empty, AspectJ)</li>
<li>Python</li>
<li>SQL</li>
<li>TeX (AlLaTeX, common, LaTeX, <strong>plain</strong>, primitive)</li>
<li>XML</li>
</ul>
<p>And the rest:<br />
ABAP (R/2 4.3, R/2 5.0, R/3 3.1, R/3 4.6C, <strong>R/3 6.10</strong>), ACSL, Ada (<strong>2005</strong>, 83, 95), Algol (60, <strong>68</strong>), Ant, Awk (<strong>gnu</strong>, POSIX), Basic (Visual), Caml (<strong>light</strong>, Objective), CIL, Clean, Cobol (1974, <strong>1985</strong>, ibm), Comal 80, command.com (WinXP), Comsol, csh, Delphi, Eiffel, Elan, erlang, Euphoria, Fortran (77, 90, <strong>95</strong>), GCL, Gnuplot, Haskell, HTML, IDL (empty, CORBA), inform, JVMIS, ksh, Lingo, Lisp (empty, Auto), Logo, make (empty, gnu), Mathematica (1.0, 3.0, <strong>5.2</strong>), Matlab, Mercury, MetaPost, Miranda, Mizar, ML, Modula-2, MuPAD, NASTRAN, Oberon-2, OCL (decorative, OMG), Octave, Oz, Pascal (Borland6, Standard, XSC), Perl, PHP, PL/I, Plasm, PostScript, POV, Prolog, Promela, PSTricks, R, Reduce, Rexx, RSL, Ruby, S (empty, PLUS), SAS, Scilab, sh, SHELXL, Simula (<strong>67</strong>, CII, DEC, IBM), SPARQL, tcl (empty, tk), VBScript, Verilog, VHDL (empty, AMS), VRML (97), XSLT</p>
<h2><span id="minted">minted</span></h2>
<p>Minted needs the package pygments:</p>
<pre class="brush: bash; title: ; notranslate">sudo apt-get install python-pygments</pre>
<h3><span id="Example">Example</span></h3>
<p><div id="attachment_23841" class="wp-caption aligncenter" style="width: 623px"><a href="http://martin-thoma.com/wp-content/uploads/2012/04/latex-java-source-minted.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/04/latex-java-source-minted.png" alt="LaTeX Java Source Code: minted" title="LaTeX Java Source Code: minted" width="613" height="232" class="size-full wp-image-23841" /></a><p class="wp-caption-text">LaTeX Java Source Code: minted</p></div><br />
This is the <a href='http://martin-thoma.com/wp-content/uploads/2012/04/minted-source-code.pdf'>PDF-file</a> produced by the following LaTeX-Code:</p>
<pre class="brush: plain; title: ; notranslate">\documentclass[a4paper,12pt]{article}
\usepackage{amssymb} % needed for math
\usepackage{amsmath} % needed for math
\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[margin=2cm]{geometry} %layout
\usepackage{minted} % needed for the inclusion of source code

\begin{document}
\renewcommand{\theFancyVerbLine}{
  \sffamily\textcolor[rgb]{0.5,0.5,0.5}{\scriptsize\arabic{FancyVerbLine}}}

\inputminted[linenos, numbersep=5pt, tabsize=4, frame=lines, label=Othello.java]{java}{Othello.java}

\end{document}</pre>
<h2><span id="Material">Material</span></h2>
<p>All files can be found in <a href='http://martin-thoma.com/wp-content/uploads/2012/04/LaTeX-Source-Code.zip'>LaTeX-Source-Code Archive</a>.</p>
<h2><span id="See_also">See also</span></h2>
<ul>
<li>WikiBook: <a href="http://en.wikibooks.org/wiki/LaTeX/Packages/Listings">LaTeX/Packages/Listings</a></li>
<li><a href="ftp://ftp.fu-berlin.de/tex/CTAN/macros/latex/contrib/listings/listings.pdf">CTAN lisings documentation</a></li>
<li><a href="http://ftp.fernuni-hagen.de/ftp-dir/pub/mirrors/www.ctan.org/macros/latex/contrib/minted/minted.pdf">CTAN minted documentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/how-to-print-source-code-with-latex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Code Jam 2012 – Round 1A 2012</title>
		<link>http://martin-thoma.com/google-code-jam-2012-round-1a-2012/</link>
		<comments>http://martin-thoma.com/google-code-jam-2012-round-1a-2012/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 04:11:22 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Code Jam]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=23361</guid>
		<description><![CDATA[3691 people are listed in the scoreboard, but 3851 tried the first problem. So I guess the number of contestants might even be higher. Problem 1 (Password Problem): Small Set: 3511/3851 users (91%) Large Set: 2329/3376 users (69%) Problem 2 (Kingdom Rush): Small Set: 1912/3466 users (55%) Large Set: 1617/1848 users (88%) Problem 3 (Cruise [...]]]></description>
			<content:encoded><![CDATA[<p>3691 people are listed in the scoreboard, but 3851 tried the first problem. So I guess the number of contestants might even be higher.</p>
<ul>
<li>Problem 1 (<a href="http://code.google.com/codejam/contest/1645485/dashboard#s=p0">Password Problem</a>):
<ul>
<li>Small Set: 3511/3851 users (91%)</li>
<li>Large Set: 2329/3376 users (69%)</li>
</ul>
</li>
<li>Problem 2 (<a href="http://code.google.com/codejam/contest/1645485/dashboard#s=p1">Kingdom Rush</a>):
<ul>
<li>Small Set: 1912/3466 users (55%)</li>
<li>Large Set: 1617/1848 users (88%)</li>
</ul>
</li>
<li>Problem 3 (<a href="http://code.google.com/codejam/contest/1645485/dashboard#s=p2">Cruise Control</a>):
<ul>
<li>Small Set: 65/312 users (21%)</li>
<li>Large Set: 22/42 users (52%)</li>
</ul>
</li>
</ul>
<p>Just as last time, you can execute these scripts by</p>
<pre class="brush: bash; title: ; notranslate">python jam.py &lt; A-small-practice.in &gt; results.txt</pre>
<p><span id="more-23361"></span></p>
<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#Passwords">1 Passwords</a></li><li><a href="#Kingdom_Rush">2 Kingdom Rush</a></li><li><a href="#Cruise_Controll">3 Cruise Controll</a></li><li><a href="#See_also">4 See also</a></li></ul></div>
<h2><span id="Passwords">Passwords</span></h2>
<p>This works only for the small input set:</p>
<pre class="brush: python; title: ; notranslate">#!/usr/bin/python
# -*- coding: utf-8 -*-

def line2floatlist(line):
	&quot;&quot;&quot; Convert integers in one line, separated by space to a
		list of integers.
	&quot;&quot;&quot;
	list = line.split(' ')
	numbers = [ float(x) for x in list ]
	return numbers

def prob(A, B, probabilities):
	typesMin = float('inf')
	for i in xrange(0, A + 1):
		probKorrect = 1.0
		for el in probabilities[0:(len(probabilities)-i)]:
			probKorrect *= el
		probWrong = 1.0 - probKorrect
		remainingTypes = i + (B - A + i) + 1
		remainingTypesErr = remainingTypes + B + 1
		types = probKorrect * remainingTypes \
				+ probWrong * remainingTypesErr
		#print types
		if types &lt; typesMin:
			typesMin = types
	if (1+B+1) &lt; typesMin:
		typesMin = (1+B+1)

	return round(typesMin , 6)
	#return typesMin

if __name__ == &quot;__main__&quot;:
	testcases = input()

	for caseNr in xrange(0, testcases):
		A, B = raw_input().split(&quot; &quot;)
		A = int(A)
		B = int(B)
		probabilities = line2floatlist(raw_input())
		#print ((A+1), B)
		#print probabilities
		print(&quot;Case #%i: %.6lf&quot; % (caseNr+1, prob(A, B, probabilities)))</pre>
<h2><span id="Kingdom_Rush">Kingdom Rush</span></h2>
<p>My solution works only for the small input set:</p>
<pre class="brush: python; title: ; notranslate">#!/usr/bin/python
# -*- coding: utf-8 -*-

from copy import deepcopy

def line2intlist(line):
	&quot;&quot;&quot; Convert integers in one line, separated by space to a
		list of integers.
	&quot;&quot;&quot;
	list = line.split(' ')
	numbers = [ int(x) for x in list ]
	return numbers

def isSolvable(starDict):
	&quot;&quot;&quot; Is it possible to solve this one? &quot;&quot;&quot;
	intList = []
	for index in starDict:
		wasInFor = True
		one, two = starDict[index]
		intList.append(one)
		intList.append(two)
	intList.sort()

	for levelVar in xrange(0, len(intList)):
		if levelVar &lt; intList[levelVar]:
			return False
	return True

def king(starDict, myLevel = 0, myCompetes = 0, partially = []):
	somethingChanged = True
	while somethingChanged:
		removeList = []
		somethingChanged = False

		#all where i can do both
		for index in starDict:
			one, two = starDict[index]
			if two &lt;= myLevel:
				removeList.append(index)
				somethingChanged = True

		#remove them
		for index in removeList:
			myCompetes += 1
			del starDict[index]
			if index in partially:
				myLevel += 1
				partially.remove(index)
			else:
				myLevel += 2

	if starDict:
		minCompetes = float('inf')
		for index in starDict:
			one, two = starDict[index]
			if one &lt;= myLevel and (index not in partially):
				starDictTmp = deepcopy(starDict)
				partiallyTmp = deepcopy(partially)
				partiallyTmp.append(index)
				tmpCompetes = king(starDictTmp, myLevel+1,
							myCompetes+1, partiallyTmp)
				if tmpCompetes &lt; minCompetes:
					minCompetes = tmpCompetes
		myCompetes = minCompetes
	return myCompetes

if __name__ == &quot;__main__&quot;:
	testcases = input()

	for caseNr in xrange(0, testcases):
		levels = input()
		stars = []
		for i in xrange(0, levels):
			stars.append(line2intlist(raw_input()))

		#make stars dictionary
		starDict = {}
		level = 1
		for el in stars:
			starDict[level] = deepcopy(el)
			level += 1

		if not isSolvable(starDict):
			print(&quot;Case #%i: Too Bad&quot; % (caseNr+1))
		else:
			print(&quot;Case #%i: %s&quot; % (caseNr+1, king(starDict)))</pre>
<h2><span id="Cruise_Controll">Cruise Controll</span></h2>
<p>Only 22 people have a perfect solution for this one. </p>
<p>This is the solution of royf:</p>
<pre class="brush: python; title: ; notranslate">
import itertools
import math
import numpy

def read_word(f):
    return next(f).strip()

def read_int(f, b=10):
    return int(read_word(f), b)

def read_letters(f):
    return list(read_word(f))

def read_digits(f, b=10):
    return [int(x, b) for x in read_letters(f)]

def read_words(f, d=' '):
    return read_word(f).split(d)

def read_ints(f, b=10, d=' '):
    return [int(x, b) for x in read_words(f, d)]

def read_arr(f, R, reader=read_ints, *args, **kwargs):
    res = []
    for i in range(R):
        res.append(reader(f, *args, **kwargs))
    return res

def solve(solver, fn, out_fn=None):
    in_fn = fn + '.in'
    if out_fn is None:
        out_fn = fn + '.out'
    with open(in_fn, 'r') as fi:
        with open(out_fn, 'w') as fo:
            T = read_int(fi)
            for i in range(T):
                case = read_case(fi)
                res = solver(case)
                write_case(fo, i, res)

################################################################################

def read_case(f):
    N = read_int(f)
    Cs = []
    for i in range(N):
        (C, S, P) = read_words(f)
        Cs.append((C, int(S), int(P)))
    return (N, Cs)

def write_case(f, i, res):
    f.write('Case #%d: '%i)
    f.write('%s'%res)
    f.write('\n')

################################################################################

INF = float('inf')

import heapq

def solve_small(case):
    (N, Cs) = case
    col = []
    for i in range(N):
        (c1, s1, p1) = Cs[i]
        for j in range(i+1, N):
            (c2, s2, p2) = Cs[j]
            if s1 == s2:
                if abs(p1-p2) &lt; 5:
                    heapq.heappush(col, (-1, True, i, j))
                continue
            t1 = (p2-p1+5)/(s1-s2)
            t2 = (p2-p1-5)/(s1-s2)
            if t1 &gt; t2:
                (t1, t2) = (t2, t1)
            if t2 &lt; 0:
                continue
            if t1 &lt; 0:
                t1 = -1
            heapq.heappush(col, (t1, True, i, j))
            heapq.heappush(col, (t2, False, i, j))
    l = [None] * N
    act = []
    for i in range(N):
        act.append(set())
    cnt = 0
    while col:
        (t, c, i, j) = heapq.heappop(col)
        if c:
            act[i].add(j)
            act[j].add(i)
        else:
            act[i].remove(j)
            act[j].remove(i)
        if t == -1:
            l[i] = Cs[i][0] == 'L'
            l[j] = Cs[j][0] == 'L'
            continue
        if c:
            if l[i] is None:
                if l[j] is None:
                    l[i] = (cnt, True)
                    l[j] = (cnt, False)
                    cnt += 1
                elif l[j] is True:
                    l[i] = False
                elif l[j] is False:
                    l[i] = True
                else:
                    (k, b) = l[j]
                    l[i] = (k, not b)
            elif l[i] is True:
                if l[j] is None:
                    l[j] = False
                elif l[j] is True:
                    return t
                elif l[j] is False:
                    pass
                else:
                    (k, b) = l[j]
                    for x in range(N):
                        if isinstance(l[x], tuple) and l[x][0] == k:
                            l[x] = b != l[x][1]
            elif l[i] is False:
                if l[j] is None:
                    l[j] = True
                elif l[j] is True:
                    pass
                elif l[j] is False:
                    return t
                else:
                    (k, b) = l[j]
                    for x in range(N):
                        if isinstance(l[x], tuple) and l[x][0] == k:
                            l[x] = b == l[x][1]
            else:
                (k, b) = l[i]
                if l[j] is None:
                    l[j] = (k, not b)
                elif l[j] is True:
                    for x in range(N):
                        if isinstance(l[x], tuple) and l[x][0] == k:
                            l[x] = b != l[x][1]
                elif l[j] is False:
                    for x in range(N):
                        if isinstance(l[x], tuple) and l[x][0] == k:
                            l[x] = b == l[x][1]
                else:
                    (k_, b_) = l[j]
                    if k == k_:
                        if b == b_:
                            return t
                        else:
                            continue
                    for x in range(N):
                        if isinstance(l[x], tuple) and l[x][0] == k:
                            l[x] = (k_, not b ^ b_ ^ l[x][1])
        else: #end col
            if not act[i]:
                l[i] = None
            if not act[j]:
                l[j] = None
    return 'Possible'

solve_large = solve_small

##def solve_large(case):

DEBUG = 'i'

from run import *</pre>
<h2><span id="See_also">See also</span></h2>
<ul>
<li>Wikipedia: <a href="http://en.wikipedia.org/wiki/Google_Code_Jam">Google Code Jam</a></li>
<li><a href="http://www.go-hero.net/jam/12/">Google Code Jam Statistics</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/google-code-jam-2012-round-1a-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX-Vorlage für ein Lastenheft</title>
		<link>http://martin-thoma.com/latex-vorlage-fur-ein-lastenheft/</link>
		<comments>http://martin-thoma.com/latex-vorlage-fur-ein-lastenheft/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 11:51:07 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[German posts]]></category>
		<category><![CDATA[KIT]]></category>
		<category><![CDATA[Lastenheft]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[MetaUML]]></category>
		<category><![CDATA[SWT I]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=23211</guid>
		<description><![CDATA[Ich habe gerade mal schnell eine Vorlage für ein Lastenheft mit LaTeX erstellt. Dieses Lastenheft beinhaltet sogar ein kleines Use-Case Beispiel, das mit MetaUML realisiert wurde. Hier ist die PDF, hier der LaTeX-Code. Das Lastenheft könnt ihr unter Linux einfach mit folgendem Befehl erstellen, wenn ihr in diesem Ordner seid: Änderungsvorschläge sind willkommen! Ich werde [...]]]></description>
			<content:encoded><![CDATA[<p>Ich habe gerade mal schnell eine Vorlage für ein Lastenheft mit LaTeX erstellt. Dieses Lastenheft beinhaltet sogar ein kleines Use-Case Beispiel, das mit MetaUML realisiert wurde. Hier ist die <a href='http://martin-thoma.com/wp-content/uploads/2012/04/Lastenheft.pdf'>PDF</a>, hier der <a href='http://martin-thoma.com/wp-content/uploads/2012/04/Lastenheft.zip'>LaTeX-Code</a>. </p>
<p>Das Lastenheft könnt ihr unter Linux einfach mit folgendem Befehl erstellen, wenn ihr in diesem Ordner seid:</p>
<pre class="brush: bash; title: ; notranslate">make</pre>
<p>Änderungsvorschläge sind willkommen! Ich werde die hier gespeicherte Version wohl noch einige male updaten.</p>
<h2>Siehe auch</h2>
<ul>
<li><a href="http://www.st.cs.uni-saarland.de/edu/se1/skript/notes.pdf">Softwaretechnik I</a>, S. 36</li>
<li><a href="http://www2.cs.uni-paderborn.de/cs/ag-schaefer/Lehre/Lehrveranstaltungen/Praktika/Softwaretechnikpraktikum/SS06/Dokumentvorlagen/Lastenheft-Template.pdf">Beispiel der Uni Paderborn</a></li>
<li><a href="http://next-internet.com/hauptstudium/texte/swt_summary.pdf">Jet Another SWT-I Resume</a>, ab S. 8</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/latex-vorlage-fur-ein-lastenheft/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Eclipse für SWT I einrichten</title>
		<link>http://martin-thoma.com/eclipse-fur-swt-i-einrichten/</link>
		<comments>http://martin-thoma.com/eclipse-fur-swt-i-einrichten/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 20:25:11 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[German posts]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[KIT]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[SWT I]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=22911</guid>
		<description><![CDATA[SWT I ist das Modul Softwaretechnik I am KIT. Dieser Blogpost richtet sich also vor allem an Studenten des KIT von Herrn Prof. Dr. Tichy. Ich arbeite außerdem mit Ubuntu Linux. Die momentan aktuellste Version nennt sich Oneiric Ocelot und kann bei UbuntuUsers heruntergeladen werden. Das System könnte z.B. in VirtualBox installiert werden. Contents1 Installation2 [...]]]></description>
			<content:encoded><![CDATA[<div class="info">SWT I ist das Modul Softwaretechnik I am <a href="http://de.wikipedia.org/wiki/Karlsruher_Institut_f%C3%BCr_Technologie">KIT</a>. Dieser Blogpost richtet sich also vor allem an Studenten des KIT von Herrn <a href="http://www.ipd.uka.de/Tichy/people.php?id=15">Prof. Dr. Tichy</a>. Ich arbeite außerdem mit Ubuntu Linux. Die momentan aktuellste Version nennt sich Oneiric Ocelot und kann bei <a href="http://wiki.ubuntuusers.de/Downloads/Oneiric_Ocelot">UbuntuUsers</a> heruntergeladen werden. Das System könnte z.B. in <a href="http://wiki.ubuntuusers.de/VirtualBox">VirtualBox</a> installiert werden.</div>
<p><span id="more-22911"></span></p>
<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#Installation">1 Installation</a></li><li><a href="#CheckStyle">2 CheckStyle</a></li><li><a href="#Subversive">3 Subversive</a></li><li><a href="#Grundeinstellungen">4 Grundeinstellungen</a></li><li><a href="#Siehe_auch">5 Siehe auch</a></li></ul></div>
<h2><span id="Installation">Installation</span></h2>
<p>Für die Installation von Java, Subversion (SVN), Eclipse und Checkstyle samt Dokumentation muss folgendes in der Konsole eingegeben werden:</p>
<pre class="brush: bash; title: ; notranslate">sudo apt-get install openjdk-6-jre openjdk-6-jdk openjdk-6-source openjdk-6-demo openjdk-6-doc openjdk-6-jre-headless openjdk-6-jre-lib subversion libapache2-svn eclipse checkstyle checkstyle-doc</pre>
<p>Dann werden etwa 276 MB an Archiven heruntergeladen und 662 MB an zusätzlichen Packeten installiert. Bei meiner Internetverbindung (DSL 1000 <img src='http://martin-thoma.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  ) hat das ca 40 Minuten gedauert.</p>
<h2><span id="CheckStyle">CheckStyle</span></h2>
<p>Siehe eclipse-cs.sourceforge.net mit <a href="http://eclipse-cs.sourceforge.net/downloads.html">detaillierten Installationsanweisungen</a>. </p>
<h2><span id="Subversive">Subversive</span></h2>
<p>Siehe eclipse.org: <a href="http://www.eclipse.org/subversive/downloads.php#indigo_stable">Download Suversive</a>.<br />
Diese Erklärung ist aber nicht so toll.</p>
<p>Nach der Installation und dem Neustart von Eclipse muss man das &#8220;Subversive Connector Kit&#8221; auswählen. Kurz in der Konsole
<pre class="brush: bash; title: ; notranslate">svn --version</pre>
<p> eingeben. Bei mir ist anscheinend Subversion in der Version 1.6.12 installiert. Also wähle ich &#8220;SVN Kit 1.3.7&#8243;.</p>
<p>Zuerst muss man den SVN Connector installieren:</p>
<pre class="brush: plain; title: ; notranslate">http://community.polarion.com/projects/subversive/download/eclipse/2.0/update-site/</pre>
<p>Das macht man wie mit CheckStyle.</p>
<p>Dann muss man Subversive installieren:</p>
<pre class="brush: plain; title: ; notranslate">http://download.eclipse.org/technology/subversive/0.7/update-site/</pre>
<p>Auch hier macht man es wie mit CheckStyle.</p>
<p>Sobald alles klappt, sieht es etwa so aus:<br />
<div id="attachment_23271" class="wp-caption aligncenter" style="width: 676px"><a href="http://martin-thoma.com/wp-content/uploads/2012/04/eclipse-subversive.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/04/eclipse-subversive.png" alt="Subversive plugin in Eclipse" title="Subversive plugin in Eclipse" width="666" height="434" class="size-full wp-image-23271" /></a><p class="wp-caption-text">Subversive plugin in Eclipse</p></div></p>
<div id="attachment_23751" class="wp-caption aligncenter" style="width: 310px"><a href="http://martin-thoma.com/wp-content/uploads/2012/04/subversive.png"><img src="http://martin-thoma.com/wp-content/uploads/2012/04/subversive-300x290.png" alt="Commit mit Subversive unter Eclipse" title="Commit mit Subversive unter Eclipse" width="300" height="290" class="size-medium wp-image-23751" /></a><p class="wp-caption-text">Commit mit Subversive unter Eclipse</p></div>
<h2><span id="Grundeinstellungen">Grundeinstellungen</span></h2>
<p>Als erstes sollte man mal auf &#8220;Window&#8221; -> &#8220;Open Perspective&#8221; -> &#8220;Java&#8221; klicken.</p>
<h2><span id="Siehe_auch">Siehe auch</span></h2>
<ul>
<li><a href="http://wiki.ubuntuusers.de/Downloads">Ubuntu Downloads</a></li>
<li><a href="http://wiki.ubuntuusers.de/Java/Installation/Oracle_Java">Oracle Java &#8211; Manuelle Installation unter Ubuntu</a>.</li>
<li>Weitere UbuntuUsers Artikel: <a href="http://wiki.ubuntuusers.de/Eclipse">Eclipse</a>, <a href="http://wiki.ubuntuusers.de/Subversion">Subversion</a></li>
<li><a href="http://martin-thoma.com/software-versioning-cheat-sheet/" title="Software Versioning Cheat Sheet">Software Versioning Cheat Sheet (Subversion / GIT)</a></li>
<li>Wikipedia: <a href="http://de.wikipedia.org/wiki/Eclipse_(IDE)">Eclipse</a>, <a href="http://de.wikipedia.org/wiki/Apache_Subversion">Subversion</a></li>
<li>Wiki Books: <a href="http://de.wikibooks.org/wiki/Java_Standard:_Erste_Schritte">Java Standard: Erste Schritte</a> (habe ich NICHT gelesen! Aber für unsere Physiker ist das eventuell hilfreich.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/eclipse-fur-swt-i-einrichten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wie berechnet man das charakteristische Polynom?</title>
		<link>http://martin-thoma.com/wie-berechnet-man-das-charakteristische-polynom/</link>
		<comments>http://martin-thoma.com/wie-berechnet-man-das-charakteristische-polynom/#comments</comments>
		<pubDate>Sat, 21 Apr 2012 11:41:39 +0000</pubDate>
		<dc:creator>Martin Thoma</dc:creator>
				<category><![CDATA[German posts]]></category>
		<category><![CDATA[lecture-notes]]></category>
		<category><![CDATA[Linear algebra]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[Wolfram|Alpha]]></category>

		<guid isPermaLink="false">http://martin-thoma.com/?p=22721</guid>
		<description><![CDATA[Will man das charakteristische Polynom einer Abbildungsmatrix berechnen, so muss man zuerst sicher im Umgang mit Determinanten sein. Contents1 Rechenregeln für Determinanten2 Berechnung des charakteristischen Polynoms3 Beispiel4 Berechnung am PC5 Wozu das Ganze?6 Siehe auch Rechenregeln für Determinanten Man darf eine Zeile mit einer Konstanten a multiplizieren, muss dann aber die Determinante durch a teilen: [...]]]></description>
			<content:encoded><![CDATA[<p>Will man das charakteristische Polynom einer Abbildungsmatrix berechnen, so muss man zuerst sicher im Umgang mit Determinanten sein.</p>
<div id="toc_container" class="toc_light_blue no_bullets"><p class="toc_title">Contents</p><ul class="toc_list"><li><a href="#Rechenregeln_fr_Determinanten">1 Rechenregeln für Determinanten</a></li><li><a href="#Berechnung_des_charakteristischen_Polynoms">2 Berechnung des charakteristischen Polynoms</a></li><li><a href="#Beispiel">3 Beispiel</a></li><li><a href="#Berechnung_am_PC">4 Berechnung am PC</a></li><li><a href="#Wozu_das_Ganze">5 Wozu das Ganze?</a></li><li><a href="#Siehe_auch">6 Siehe auch</a></li></ul></div>
<h2><span id="Rechenregeln_fr_Determinanten">Rechenregeln für Determinanten</span></h2>
<p>Man darf eine <strong>Zeile mit einer Konstanten a multiplizieren</strong>, muss dann aber die Determinante durch a teilen:<br />
<span id="more-22721"></span><br />
\(<br />
det \begin{pmatrix}<br />
3 &#038; 2 &#038; 12 &#038; 5 \\<br />
2 &#038; 1 &#038;  6 &#038; 4 \\<br />
2 &#038; 0 &#038;  2 &#038; -3\\<br />
2 &#038; 2 &#038;  7 &#038; 4<br />
\end{pmatrix}<br />
\begin{array}{c} | \cdot 2 \\ | \cdot 3 \\ | \cdot 3 \\ | \cdot 3 \end{array}<br />
 = \frac{1}{2} \cdot (\frac{1}{3})^3 \cdot<br />
det \begin{pmatrix}<br />
6 &#038; 4 &#038; 24 &#038; 10 \\<br />
6 &#038; 3 &#038; 18 &#038; 12 \\<br />
6 &#038; 0 &#038;  6 &#038; -9\\<br />
6 &#038; 6 &#038; 21 &#038; 12<br />
\end{pmatrix}<br />
\)</p>
<p>Man darf zwei <strong>Zeilen / Spalten tauschen</strong>, muss dann aber die Determinante mit (-1) multiplizieren:<br />
\(det \begin{pmatrix}<br />
6 &#038; 4 &#038; 24 &#038; 10 \\<br />
6 &#038; 3 &#038; 18 &#038; 12 \\<br />
6 &#038; 0 &#038;  6 &#038; -9\\<br />
6 &#038; 6 &#038; 21 &#038; 12<br />
\end{pmatrix} \begin{array}{c} \cdot  \\  \cdot \\ \leftarrow \\ \leftarrow \end{array} = -<br />
det \begin{pmatrix}<br />
6 &#038; 4 &#038; 24 &#038; 10 \\<br />
6 &#038; 3 &#038; 18 &#038; 12 \\<br />
6 &#038; 6 &#038; 21 &#038; 12 \\<br />
6 &#038; 0 &#038;  6 &#038; -9<br />
\end{pmatrix} =<br />
det \begin{pmatrix}<br />
6 &#038; 24 &#038; 4 &#038; 10 \\<br />
6 &#038; 18 &#038; 3 &#038; 12 \\<br />
6 &#038; 21 &#038; 6 &#038; 12 \\<br />
6 &#038; 6  &#038; 0 &#038; -9<br />
\end{pmatrix}\)</p>
<p>Man darf eine <strong>Zeile mit einer Konstanten multiplizieren und auf eine beliebige <em>andere</em> Zeile addieren</strong> (wie beim Gauss-Verfahren)</p>
<p>Man darf eine <strong>Zeile und eine Spalte zugleich entfernen</strong> (Entwicklung nach Spalte / Zeile xy), muss dann aber folgendermaßen ausgleichen:<br />
Entwicklung nach der k-ten Spalte: \(D(a_1, &#8230; , a_n) = \sum_{j=1}^{n}(-1)^{k+j}a_{jk}D_{jk}\)<br />
Entwicklung nach der i-ten Zeile: \(det A = \sum_{k=1}^n (-1)^{i+k}a_{ik}D_{ik}\)<br />
Direkt entfernen, ohne etwas weiteres zu beachten, kann man die Zeile, wenn in dieser Zeile nur eine 1 steht und diese 1 an einer ungeraden Spalte (1, &#8230;, n) ist.<br />
Eine Spalte kann man direkt entfernen, wenn in der Spalte nur an einer Stelle eine 1 steht und diese 1 an einer ungeraden Zeile (1, &#8230;, n) steht.</p>
<h2><span id="Berechnung_des_charakteristischen_Polynoms">Berechnung des charakteristischen Polynoms</span></h2>
<p>Das charakteristische Polynom einer Abbildungsmatrix A ist der Wert folgender Determinanten:<br />
\(det(\lambda \cdot E_n &#8211; A)\), wobei \(E_n\) die Einheitsmatrix ist.</p>
<h2><span id="Beispiel">Beispiel</span></h2>
<p>Siehe <a href="http://de.wikipedia.org/wiki/Charakteristisches_Polynom#Beispiel">Wikipedia</a>.</p>
<h2><span id="Berechnung_am_PC">Berechnung am PC</span></h2>
<p>Mit Wolfram|Alpha kann man das <a href="http://www.wolframalpha.com/widgets/view.jsp?id=27ddb8d522a2dc74e89687bd357db5a0">charakteristische Polynom</a> berechnen und auch direkt die <a href="http://www.wolframalpha.com/input/?i=Eigenvalues%7B%7B1%2C0%2C1%7D%2C%7B2%2C2%2C1%7D%2C%7B4%2C2%2C1%7D%7D">Eigenwerte</a>.</p>
<h2><span id="Wozu_das_Ganze">Wozu das Ganze?</span></h2>
<p>An dem charakteristischem Polynom kann man direkt die Eigenwerte ablesen. Existiert eine Basis aus Eigenvektoren für den Vektorraum, dann ist eine Matrix diagonalsiierbar. Wenn eine Matrix in Diagonalform ist, dann kann man damit besonders gut rechnen.</p>
<h2><span id="Siehe_auch">Siehe auch</span></h2>
<ul>
<li>Wikipedia: <a href="http://de.wikipedia.org/wiki/Determinante">Determinante</a>, <a href="http://de.wikipedia.org/wiki/Charakteristisches_Polynom">Charakteristisches Polynom</a>, <a href="http://de.wikipedia.org/wiki/Eigenwertproblem">Eigenwertproblem</a>, <a href="http://de.wikipedia.org/wiki/Diagonalmatrix">Diagonalmatrix</a></li>
<li>Skript von Herrn Prof. Dr. Leuzinger, S. 131 &#8211; 142: Determinanten.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://martin-thoma.com/wie-berechnet-man-das-charakteristische-polynom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

