Bool done

This commit is contained in:
Jan Grewe 2014-10-08 14:56:48 +02:00
parent 4851365afc
commit e81498d095
7 changed files with 114 additions and 59 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

View File

@ -672,52 +672,91 @@
\begin{frame}[plain]
\huge{Boolesche Operationen}
\huge{3. Boolesche Operationen}
\end{frame}
\begin{frame}
\frametitle{Boolesche Operationen}
\framesubtitle{Was ist das?}\pause
\frametitle{Boolesche Operationen} \framesubtitle{Was ist das?}
Boolesche Operationen sind Operationen, die sich zu Wahr oder Falsch
auswerten lassen. Auf Mengen angewendet (Zeichnungen geklaut bei
Cornelia M\"uhlich, Uni-Jena):
\only<1> {
\begin{figure}
\centering
\includegraphics[width=0.75\columnwidth]{./images/grundmenge}
\end{figure}
}
\only<2> {
\begin{figure}
\centering
\includegraphics[height=0.65\textheight]{./images/beete}
\end{figure}
}
\only<3> {
\begin{figure}
\centering
\includegraphics[height=0.65\textheight]{./images/AvB}
\end{figure}
}
\only<4> {
\begin{figure}
\centering
\includegraphics[height=0.65\textheight]{./images/AundB}
\end{figure}
}
\only<5> {
\begin{figure}
\centering
\includegraphics[height=0.65\textheight]{./images/AnotB}
\end{figure}
}
\only<6> {
\begin{figure}
\centering
\includegraphics[height=0.65\textheight]{./images/AxorB}
\end{figure}
}
\end{frame}
\begin{frame}
\begin{frame}[fragile]
\frametitle{Boolesche Operationen}
\framesubtitle{Logische Operatoren}
\begin{table}[th]
\begin{center}
\begin{tabular}{c|c}
\hline
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
$\sim$ & logisches NOT\\
$\&$ & logisches UND\\
$|$ & logisches ODER\\
$\&\&$ & short-circuit logical AND\\
$\|$ & short-circuit logical OR\\
\hline
\end{tabular}
\end{center}
Das auschliessende ODER (XOR) ist nur als Funktion \verb+xor(A, B)+ verf\"ugbar.
\end{table}
\caption{\label{logicalOperatorsTab}
\textbf{Logical operators.}}
\begin{center}
\begin{tabular}{c|c}
\hline
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
$\sim$ & logisches NOT\\
$\&$ & logisches UND\\
$|$ & logisches ODER\\
$\&\&$ & short-circuit logical AND\\
$\|$ & short-circuit logical OR\\
\hline
\end{tabular}
\end{center}
\vspace{1em}
Das auschliessende ODER (XOR) ist nur als Funktion \verb+xor(A, B)+ verf\"ugbar.
\end{table}
\end{frame}
\subsection{Relational operators}
\begin{frame}
\begin{frame}[fragile]
\frametitle{Boolesche Operationen}
\framesubtitle{Relationale Operatoren}
\begin{table}[th]
\caption{\label{relOperatorsTab}
\textbf{Relational Operators.}}
\begin{center}
\begin{tabular}{c|c}
\hline
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
$<$ & kleiner als\\
$>$ & gr\"o\{ss}er als \\
$>$ & gr\"osser als \\
$==$ & gleich \\
$>=$ & gr\"o\{ss}er oder gleich\\
$<=$ & kleiner oder gleich\\
$>=$ & gr\"osser oder gleich \\
$<=$ & kleiner oder gleich \\
$\sim=$ & ungleich\\
\hline
\end{tabular}
@ -725,13 +764,12 @@
\end{table}
\end{frame}
\subsection{Logical operators}
\subsection{Boolean operations}
\begin{frame}[fragile]{Boolean operations}{Examples}
\tiny
\begin{lstlisting}[label=booleanListing1]
\begin{frame}[fragile]
\frametitle{Boolean operations}
\framesubtitle{Beispiele}
\tiny
\begin{lstlisting}
>> x = [2 0 0 5 0] & [1 0 3 2 0]
x =
1 0 0 1 0
@ -743,33 +781,50 @@
>> [2 0 0 5 0] | [1 0 3 2 0]
ans =
1 0 1 1 0
\end{lstlisting}
\end{frame}
\subsection{Exercises}
\begin{frame}[fragile]{Boolean operations}{Exercises}
\vspace{-0.5cm}
\begin{enumerate}
\item Given are two vectors \verb+x = [1 5 2 8 9 0 1]+ and
\verb+y = [5 2 2 6 0 0 2]+. Execute and explain the following commands.
\begin{enumerate}
\item \verb+x > y+
\item \verb+y < x+
\item \verb+x == y+
\item \verb+x ~= y+
\item \verb+x & ~y+
\item \verb+x | y+
\end{enumerate}
\item One can use boolean operations for so called logical indexing:
Given are \verb+x = 1:10+ and \verb+y = [3 1 5 6 8 2 9 4 7 0]+. Try
to understand the following commands.
\begin{enumerate}
\item \verb+x( (y <= 2) )+
\item \verb+x( (x > 2) | (y < 8) )+
\item \verb+x( (x == 0) & (y == 0) )+
\end{enumerate}
\item Play around with boolean operations.
\end{enumerate}
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Boolesche Operationen}
\framesubtitle{\"Ubungen}
\vspace{-0.5cm}
\begin{enumerate}
\item Gegeben sind zwei Vektoren \verb+x = [1 5 2 8 9 0 1]+ und
\verb+y = [5 2 2 6 0 0 2]+. F\"uhre aus und erkl\"are.
\begin{enumerate}
\item \verb+x > y+
\item \verb+y < x+
\item \verb+x == y+
\item \verb+x ~= y+
\item \verb+x & ~y+
\item \verb+x | y+
\end{enumerate}
\end{enumerate}
\end{frame}
\begin{frame}[fragile]
\frametitle{Logische Indexierung}
\framesubtitle{\"Ubungen}
Boolesche Operationen koennen eingesetzt werden um aus Vektoren und
Matrizen Elemente auszuwaehlen, die einer bestimmten Bedingung
entsprechen.
\begin{enumerate}
\item Gegeben sind \verb+x = (1:10)+ und
\verb+y = [3 1 5 6 8 2 9 4 7 0]+. Try to understand the following
commands.
\begin{enumerate}
\item \verb+x( (y <= 2) )+
\item \verb+x( (x > 2) | (y < 8) )+
\item \verb+x( (x == 0) \& (y == 0) )+
\end{enumerate}
\item Erzeuge eine 100x100 2-D Matrix mit Zufallswerten zwischen 0 und 100 (\verb+randi+). Ersetze \verb+x < 33+ mit 0, \verb+x >= 33 und x < 66+ mit 1 und alle \verb+x >= 66+ auf 2.
\item Ermittle die Anzahl Elemente fuer jede Klasse mithilfe eines Booleschen Ausdrucks.
\end{enumerate}
\end{frame}
\end{document}