Commit a3d1e2d4 authored by Jurgis Pods's avatar Jurgis Pods
Browse files

[doc] Update doc

parent a7bc3d7d
No preview for this file type
......@@ -16,7 +16,7 @@
\usepackage{scrpage2}
\pagestyle{scrheadings}
\lehead{DUNE Course, Heidelberg 2014}
\lehead{DUNE Course, Heidelberg \the\year}
\cehead{}
\rehead{\headmark}
\lohead{\headmark}
......@@ -58,19 +58,20 @@
\usepackage{hyperref}
\setkomafont{pagenumber}{\normalfont\scshape}
\setkomafont{pagehead}{\normalfont\scshape}
\lstset{language=C++, basicstyle=\small\ttfamily,
keywordstyle=\bfseries, tabsize=4, stringstyle=\ttfamily,
commentstyle=\it, extendedchars=true, escapeinside={/*@}{@*/}}
%\lstset{language=C++, basicstyle=\small\ttfamily,
% tabsize=4, stringstyle=\ttfamily,
% keywordstyle=\color{violet},
% commentstyle=\color{darkgray},
% stringstyle=\color{orange},
% emph={bool,int,unsigned,char,true,false,void}, emphstyle=\color{blue},
% emph={[2]\#include,\#define,\#ifdef,\#endif}, emphstyle={[2]\color{violet}},
% emph={[3]Dune,Grid,GridView,LeafGridView,LevelGridView,SomeGrid,TheGrid,LeafIterator,Iterator,LevelIterator,LeafIntersectionIterator,LevelIntersectionIterator,IntersectionIterator,LeafMultipleCodimMultipleGeomTypeMapper,Geometry,Entity,EntityPointer,Codim,FieldVector,FieldMatrix}, emphstyle={[3]\color{blue}},
% extendedchars=true, escapeinside={/*@}{@*/}}
% \lstset{language=C++, basicstyle=\small\ttfamily,
% keywordstyle=\bfseries, tabsize=4, stringstyle=\ttfamily,
% commentstyle=\it, extendedchars=true, escapeinside={/*@}{@*/}}
\lstset{language=C++, basicstyle=\small\ttfamily,
tabsize=4, stringstyle=\ttfamily,
keywordstyle=\color{violet},
commentstyle=\color{darkgray},
stringstyle=\color{orange},
emph={bool,int,unsigned,char,true,false,void}, emphstyle=\color{blue},
emph={[2]\#include,\#define,\#ifdef,\#endif}, emphstyle={[2]\color{violet}},
emph={[3]Dune,Grid,GridView,LeafGridView,LevelGridView,SomeGrid,TheGrid,LeafIterator,Iterator,LevelIterator,LeafIntersectionIterator,LevelIntersectionIterator,IntersectionIterator,LeafMultipleCodimMultipleGeomTypeMapper,Geometry,Entity,EntityPointer,Codim,FieldVector,FieldMatrix}, emphstyle={[3]\color{blue}},
extendedchars=true, escapeinside={/*@}{@*/}}
%The theorems
......@@ -164,8 +165,8 @@
\subsection*{Introduction}
\begin{onlyenv}<article>
As presented in the lecture templates are a common generic
programming technique. They allow the design of algorithms independent on
As presented in the lecture, templates are a common generic
programming technique. They allow the design of algorithms independent of
a specific datatype.\\
In these exercises:
......@@ -177,18 +178,18 @@ In these exercises:
\begin{frame}[fragile]
\frametitle{Templates}
Matrices are a central data structure in numerics and therefore used very often.
Matrices are a central data structure in numerics and therefore used frequently.
Suppose we have the following situation:
\begin{itemize}
\item We already have an implementation of a class \lstinline!MatrixClass!
representing 2D matrices of elements of type \lstinline!double!
representing 2D matrices of elements of type \lstinline!double!.
\item In our applications we often want to have matrices of other
types of elements (\lstinline!int!, \lstinline!complex!, \ldots)
types of elements (\lstinline!int!, \lstinline!complex!, \ldots).
\begin{itemize}
\item One possibility is to implement a \lstinline!MatrixClass! for each type of
element. This results in a lot of (redundant) code that is not easily
maintainable.
\item We want therefore to create a template class \lstinline!MatrixClass!\\
\item We therefore want to create a template class \lstinline!MatrixClass!\\
($\rightarrow$ better code reuse, easier to maintain).
\end{itemize}
\end{itemize}
......@@ -236,7 +237,7 @@ arithmetic operations \lstinline!*=! and \lstinline!+=!:
\begin{frame}[fragile]
\frametitle{MatrixClass (matrix\_double.h)}
\lstinputlisting[basicstyle=\scriptsize\ttfamily]
{../../c++-exercise1/matrix_double/matrix_double.h}
{../matrix_double/matrix_double.h}
\end{frame}
%-----------------------------------------------------------------------------
......@@ -245,7 +246,7 @@ arithmetic operations \lstinline!*=! and \lstinline!+=!:
\begin{frame}[fragile]
\frametitle{Test the implementation (test\_matrix\_double.cc)}
\lstinputlisting[basicstyle=\scriptsize\ttfamily]
{../../c++-exercise1/matrix_double/test_matrix_double.cc}
{../matrix_double/test_matrix_double.cc}
\end{frame}
%-----------------------------------------------------------------------------
......@@ -266,9 +267,10 @@ Note: The non-class functions
\end{itemize}
have to be changed into template functions.
\emph{Hint}: If you encounter problems linking your application, you might want to have
a glimpse at the last paragraph on this website:
\href{http://www.cplusplus.com/doc/tutorial/templates/}{http://www.cplusplus.com/doc/tutorial/templates/}
\emph{Hint}: If you encounter problems linking your application, you probably implemented the
templated matrix using the common technique of separating header (interface) and source (implementation) files.
That is not possible using templates! Have a look at this Stackoverflow question for details: \href{http://stackoverflow.com/q/495021/2429404}{http://stackoverflow.com/q/495021/2429404}.
The short version is: put everything in the header file!
\end{block}
\end{frame}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment