diff --git a/20230504/Zeichen_123.pdf b/20230504/Zeichen_123.pdf new file mode 120000 index 0000000000000000000000000000000000000000..fdbc897227df059cfda790a16555e6e417682116 --- /dev/null +++ b/20230504/Zeichen_123.pdf @@ -0,0 +1 @@ +../common/Zeichen_123.pdf \ No newline at end of file diff --git a/20230504/ad-20230504.pdf b/20230504/ad-20230504.pdf new file mode 100644 index 0000000000000000000000000000000000000000..963485438c35e18f438e0b32cfc758398b14df8d Binary files /dev/null and b/20230504/ad-20230504.pdf differ diff --git a/20230504/ad-20230504.tex b/20230504/ad-20230504.tex new file mode 100644 index 0000000000000000000000000000000000000000..4a993102f4b4b3c452d00f25fa2692e32e111ca4 --- /dev/null +++ b/20230504/ad-20230504.tex @@ -0,0 +1,417 @@ +% ad-20230504.pdf - Lecture Slides on Algorithms and Data Structures in C/C++ +% Copyright (C) 2018, 2019, 2020, 2021, 2022, 2023 Peter Gerwinski +% +% This document is free software: you can redistribute it and/or +% modify it either under the terms of the Creative Commons +% Attribution-ShareAlike 3.0 License, or under the terms of the +% GNU General Public License as published by the Free Software +% Foundation, either version 3 of the License, or (at your option) +% any later version. +% +% This document is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this document. If not, see <http://www.gnu.org/licenses/>. +% +% You should have received a copy of the Creative Commons +% Attribution-ShareAlike 3.0 Unported License along with this +% document. If not, see <http://creativecommons.org/licenses/>. + +% README: Gruppen, Ringe, Körper + +\documentclass[10pt,t]{beamer} + +\usepackage{pgslides} +\usepackage{tikz} +%\usepackage{rotating} + +\newcommand{\underconstruction}{% + \begin{picture}(0,0) + \color{black} + \put(6,-2.2){\makebox(0,0)[b]{\includegraphics[width=1.5cm]{Zeichen_123.pdf}}} + \put(6,-2.5){\makebox(0,0)[t]{\shortstack{Änderungen\\vorbehalten}}} + \end{picture}} + +\title{Algorithmen und Datenstrukturen in C/C++} +\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski} +\date{4.\ Mai 2023} + +\begin{document} + +\maketitleframe + +\nosectionnonumber{\inserttitle} + +\begin{frame} + + \shownosectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \underconstruction + \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/ad.git}}} + \begin{itemize} + \vspace*{-\smallskipamount} + \item[\dots] + \item[1.8] Templates + \item[1.9] Container-Templates + \item[1.10] Iteratoren + \color{medgreen} + \item[1.11] Exceptions + \item[1.12] Typ-Konversionen + \item[1.13] Intelligente Zeiger + \end{itemize} + \item[\textbf{2}] \textbf{Datenorganisation} +% \begin{itemize} +% \item Listen, Bäume, Hash-Tabellen, \dots +% \end{itemize} + \item[\textbf{3}] \textbf{Datenkodierung} + \begin{itemize} + \item[3.\boldmath$(x^2 - 1)$\hspace*{-2.789em}]\hspace*{2.789em}Mathematische Grundlagen + \end{itemize} + \item[\textbf{4}] \textbf{Hardwarenahe Algorithmen} +% \begin{itemize} +% \item FFT, CORDIC, \dots +% \end{itemize} + \item[\textbf{5}] \textbf{Optimierung} +% \begin{itemize} +% \item Wegfindung, \dots +% \end{itemize} + \color{gray} + \item[\textbf{6}] \textbf{Numerik} + \end{itemize} + +\end{frame} + +\section{Einführung in C++} +\setcounter{subsection}{12} + +\subsection{Intelligente Zeiger} + +\begin{frame}[fragile] + \showsection + \showsubsection + + \textbf{Warum?} + \begin{itemize} + \item + bereits freigegebene Zeiger werden u.\,U.\ weiterhin verwendet + \item + Speicherlecks + \item + uninitialisierte Zeiger + \end{itemize} + + \medskip + + \begin{itemize} + \item + \lstinline{shared_ptr} + \item + \lstinline{weak_ptr} + \item + \lstinline{unique_ptr} + \item + \lstinline{move()} + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \showsection + \showsubsection + + \textbf{Wie?} + \begin{itemize} + \item + R-Wert-Referenztypen: \lstinline{&&} + \item + \lstinline{move()}-Funktion + \end{itemize} + + \bigskip + + Literatur: + \begin{itemize} + \item + \url{http://thbecker.net/articles/rvalue_references/section_01.html} + \item + \url{http://www.artima.com/cppsource/rvalue.html} + \end{itemize} +\end{frame} + +\setcounter{subsection}{10} +\subsection{Exceptions} + +\begin{frame}[fragile] + \showsubsection + \begin{lstlisting} + try + { + ... + throw <value>; + ... + } + catch (<type> <variable>) + { + ... + } + catch ... + \end{lstlisting} + \vspace*{-4.6cm}\hspace*{5cm} + \begin{minipage}{7cm} + \begin{itemize} + \item + Nach den \lstinline{catch()}-Statements wird, + soweit nicht anders programmiert, das Programm fortgesetzt. + \medskip + \item + \lstinline{throw;} (ohne Wert):\\ + an übergeordneten Exception-Handler weiterreichen + \medskip + \item + C-Äquivalent:\\ + \lstinline{setjmp()}, \lstinline{longjmp()} + \medskip + \item + speziell für \lstinline{<type>}:\\ + Nachfahren von \lstinline{class exception} + \medskip + \item + veraltet:\\ + \newterm{dynamic exception specifications} + \end{itemize} + \end{minipage} +\end{frame} + +\subsection{Typ-Konversionen} + +\begin{frame}[fragile] + \showsubsection + + \begin{itemize} + \item + In C: + \begin{lstlisting}[gobble=8] + char *hello = "Hello, world!"; + uint64_t address = (uint64_t) hello; + printf ("%" PRIu64 "\n", address); + \end{lstlisting} + \smallskip + \item + alternative Syntax in C++: + \begin{lstlisting}[gobble=8] + char *hello = "Hello, world!"; + uint64_t address = uint64_t (hello); + cout << address << endl; + \end{lstlisting} + \smallskip + \item + zusätzlich in C++:\\ + implizite und explizite Typumwandlung zwischen Zeigern auf Klassen\\ + \lstinline{dynamic_cast<>()}\\ + \lstinline{static_cast<>()}\\ + \lstinline{reinterpret_cast<>()}\\ + \lstinline{const_cast<>()} + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \showsubsection + + \url{http://www.cplusplus.com/doc/tutorial/typecasting/} + + \begin{itemize} + \item + Zuweisung: Zeiger auf abgeleitete Klasse an Zeiger auf Basisklasse\\ + \textarrow\ implizite Typumwandlung möglich + \smallskip + \item + Zuweisung: Zeiger auf Basisklasse an Zeiger auf abgeleitete Klasse\\ + \textarrow\ nur explizite Typumwandlung möglich:\\ + \hspace*{0.76cm}\lstinline{dynamic_cast<>()}, \lstinline{static_cast<>()} + \smallskip + \item + implizite Typumwandlungen in der Klasse definieren: + \begin{itemize} + \item + Initialisierung durch Konstruktor + \item + Zuweisungs-Operator + \item + Typumwandlungsoperator + \end{itemize} + \smallskip + \item + implizite Typumwandlungen ausschalten:\\ + Schlüsselwort \lstinline{explicit} + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \showsubsection + + \url{http://www.cplusplus.com/doc/tutorial/typecasting/} + + \begin{itemize} + \item + \lstinline{dynamic_cast<>()}\\ + Zuweisung: Zeiger auf Basisklasse an Zeiger auf abgeleitete Klasse\\ + explizite Typumwandlung mit Prüfung, ggf.\ Exception + \smallskip + \item + \lstinline{static_cast<>()}\\ + Zuweisung: Zeiger auf Basisklasse an Zeiger auf abgeleitete Klasse\\ + explizite Typumwandlung ohne Prüfung + \smallskip + \item + \lstinline{reinterpret_cast<>()}\\ + Typumwandlung ohne Prüfung zwischen Zeigern untereinander\\ + und zwischen Zeigern und Integer-Typen + \smallskip + \item + \lstinline{const_cast<>()}\\ + "`\lstinline{const}"' ein- bzw.\ ausschalten + \end{itemize} +\end{frame} + +\setcounter{section}{2} +\section{Datenkodierung} +\subsectionnonumber{\boldmath 3.$(x^2 - 1)$\quad Der Herr der Ringe: Manchmal ist $1 + 1 = 0$.} +\subsubsectionnonumber{\boldmath 3.$(x^2 - 1).x$\quad Motivation} + +\begin{frame} + + \showsection + \pause + \showsubsectionnonumber + \pause + \showsubsubsectionnonumber + + Man kann auch mit sehr merkwürdigen Objekten\\ + wie mit "`ganz normalen"' Zahlen rechnen. + + \pause + \bigskip + + Anwendungen: + \begin{itemize} + \item Funktionsweise von Computern (\textarrow\ Rechnertechnik) + \item Fehlererkennung + \item Fehlerkorrektur + \item Verschlüsselung + \item Digitale Signaturen + \end{itemize} + +\end{frame} + +\subsubsectionnonumber{\boldmath 3.$(x^2 - 1).(x + 1)$\quad Gruppen} + +\begin{frame} + + \showsection + \showsubsectionnonumber + \showsubsubsectionnonumber + + \textbf{Definition:} + Sei $G$ eine Menge, $*$ eine Verknüpfung auf $G$. + Wenn + \begin{itemize} + \item + $\forall a, b, c \in G$: $(a * b) * c = a * (b * c)$ \quad (Assoziativgesetz), + \item + $\exists e \in G$: $\forall a \in G$: $a * e = e * a = a$ \quad (neutrales Element), + \item + $\forall a \in G$: $\exists a^{-1} \in G$: $a * a^{-1} = a^{-1} * a = e$ \quad (inverses Element), + \end{itemize} + dann heißt $(G,*)$ eine \newterm{Gruppe}. + + \pause + \bigskip + + \textbf{Definition:} + Sei $(G,*)$ eine Gruppe. + Wenn zusätzlich + \begin{itemize} + \item + $\forall a, b \in G$: $a * b = b * a$ \quad (Kommutativgesetz), + \end{itemize} + dann heißt $(G,*)$ eine \newterm{kommutative Gruppe}. + +\end{frame} + +\subsubsectionnonumber{\boldmath 3.$(x^2 - 1).(x + 2)$\quad Ringe} + +\begin{frame} + +% \showsection + \showsubsectionnonumber + \showsubsubsectionnonumber + + \textbf{Definition:} + Sei $R$ eine Menge; seien $+$ und $\cdot$ Verknüpfungen auf $R$. + Wenn + \begin{itemize} + \item + $(R,+)$ eine kommutative Gruppe ist, + \item + $\forall a, b, c \in R$: $(a \cdot b) \cdot c = a \cdot (b \cdot c)$ \quad (Assoziativgesetz), + \item + $\forall a, b, c \in R$: $(a + b)\cdot c = a\cdot c + b\cdot c$ + und $a\cdot(b + c) = a\cdot b + a\cdot c$ \quad (Distributivgesetze), + \end{itemize} + dann heißt $(R,+,\cdot)$ ein \newterm{Ring}. + + \pause + \bigskip + + \textbf{Definition:} + Sei $(R,+,\cdot)$ ein Ring. + Wenn zusätzlich + \begin{itemize} + \item + $\forall a, b \in R$: $a \cdot b = b \cdot a$ \quad (Kommutativgesetz), + \end{itemize} + dann heißt $(R,+,\cdot)$ ein \newterm{kommutativer Ring}. + + \pause + \bigskip + + \textbf{Definition:} + Sei $(R,+,\cdot)$ ein (kommutativer) Ring. + Wenn zusätzlich + \begin{itemize} + \item + ein $e \in R$ existiert, so daß für alle $a \in R$ gilt: $a \cdot e = e \cdot a = a$\\ + (neutrales Element), + \end{itemize} + dann heißt $(R,+,\cdot)$ ein \newterm{(kommutativer) Ring mit 1}. + + \vspace*{-1cm} + +\end{frame} + +\subsubsectionnonumber{\boldmath 3.$(x^2 - 1).(x + 3)$\quad Körper} + +\begin{frame} + +% \showsection + \showsubsectionnonumber + \showsubsubsectionnonumber + + \textbf{Definition:} + Sei $K$ eine Menge; seien $+$ und $\cdot$ Verknüpfungen auf $K$. + Wenn + \begin{itemize} + \item + $(K,+,\cdot)$ ein Ring mit 1 ist und + \item + $(K \backslash \{0\},\cdot)$ eine kommutative Gruppe ist, + \end{itemize} + dann heißt $(K,+,\cdot)$ ein \newterm{Körper}. + +\end{frame} + +\end{document} diff --git a/20230504/logo-hochschule-bochum-cvh-text.pdf b/20230504/logo-hochschule-bochum-cvh-text.pdf new file mode 120000 index 0000000000000000000000000000000000000000..a05946126bc0ce6a2818740da2893f59eb0c659c --- /dev/null +++ b/20230504/logo-hochschule-bochum-cvh-text.pdf @@ -0,0 +1 @@ +../common/logo-hochschule-bochum-cvh-text.pdf \ No newline at end of file diff --git a/20230504/logo-hochschule-bochum.pdf b/20230504/logo-hochschule-bochum.pdf new file mode 120000 index 0000000000000000000000000000000000000000..b6b9491e370e499c9276918182cdb82cb311bcd1 --- /dev/null +++ b/20230504/logo-hochschule-bochum.pdf @@ -0,0 +1 @@ +../common/logo-hochschule-bochum.pdf \ No newline at end of file diff --git a/20230504/pgslides.sty b/20230504/pgslides.sty new file mode 120000 index 0000000000000000000000000000000000000000..5be1416f4216f076aa268901f52a15d775e43f64 --- /dev/null +++ b/20230504/pgslides.sty @@ -0,0 +1 @@ +../common/pgslides.sty \ No newline at end of file