Bool done
This commit is contained in:
parent
4851365afc
commit
e81498d095
BIN
programming/lectures/images/AnotB.png
Normal file
BIN
programming/lectures/images/AnotB.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
BIN
programming/lectures/images/AundB.png
Normal file
BIN
programming/lectures/images/AundB.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
BIN
programming/lectures/images/AvB.png
Normal file
BIN
programming/lectures/images/AvB.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
BIN
programming/lectures/images/AxorB.png
Normal file
BIN
programming/lectures/images/AxorB.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
BIN
programming/lectures/images/beete.png
Normal file
BIN
programming/lectures/images/beete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 302 KiB |
BIN
programming/lectures/images/grundmenge.png
Normal file
BIN
programming/lectures/images/grundmenge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
@ -672,52 +672,91 @@
|
|||||||
|
|
||||||
|
|
||||||
\begin{frame}[plain]
|
\begin{frame}[plain]
|
||||||
\huge{Boolesche Operationen}
|
\huge{3. Boolesche Operationen}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\begin{frame}
|
\begin{frame}
|
||||||
\frametitle{Boolesche Operationen}
|
\frametitle{Boolesche Operationen} \framesubtitle{Was ist das?}
|
||||||
\framesubtitle{Was ist das?}\pause
|
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}
|
\end{frame}
|
||||||
|
|
||||||
|
\begin{frame}[fragile]
|
||||||
\begin{frame}
|
|
||||||
\frametitle{Boolesche Operationen}
|
\frametitle{Boolesche Operationen}
|
||||||
\framesubtitle{Logische Operatoren}
|
\framesubtitle{Logische Operatoren}
|
||||||
\begin{table}[th]
|
\begin{table}[th]
|
||||||
\begin{center}
|
\caption{\label{logicalOperatorsTab}
|
||||||
\begin{tabular}{c|c}
|
\textbf{Logical operators.}}
|
||||||
\hline
|
\begin{center}
|
||||||
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
|
\begin{tabular}{c|c}
|
||||||
$\sim$ & logisches NOT\\
|
\hline
|
||||||
$\&$ & logisches UND\\
|
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
|
||||||
$|$ & logisches ODER\\
|
$\sim$ & logisches NOT\\
|
||||||
$\&\&$ & short-circuit logical AND\\
|
$\&$ & logisches UND\\
|
||||||
$\|$ & short-circuit logical OR\\
|
$|$ & logisches ODER\\
|
||||||
\hline
|
$\&\&$ & short-circuit logical AND\\
|
||||||
\end{tabular}
|
$\|$ & short-circuit logical OR\\
|
||||||
\end{center}
|
\hline
|
||||||
Das auschliessende ODER (XOR) ist nur als Funktion \verb+xor(A, B)+ verf\"ugbar.
|
\end{tabular}
|
||||||
\end{table}
|
\end{center}
|
||||||
|
\vspace{1em}
|
||||||
|
Das auschliessende ODER (XOR) ist nur als Funktion \verb+xor(A, B)+ verf\"ugbar.
|
||||||
|
\end{table}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
|
|
||||||
\subsection{Relational operators}
|
\begin{frame}[fragile]
|
||||||
\begin{frame}
|
|
||||||
\frametitle{Boolesche Operationen}
|
\frametitle{Boolesche Operationen}
|
||||||
\framesubtitle{Relationale Operatoren}
|
\framesubtitle{Relationale Operatoren}
|
||||||
\begin{table}[th]
|
\begin{table}[th]
|
||||||
|
\caption{\label{relOperatorsTab}
|
||||||
|
\textbf{Relational Operators.}}
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{tabular}{c|c}
|
\begin{tabular}{c|c}
|
||||||
\hline
|
\hline
|
||||||
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
|
\textbf{Operator} & \textbf{Beschreibung} \\ \hline
|
||||||
$<$ & kleiner als\\
|
$<$ & kleiner als\\
|
||||||
$>$ & gr\"o\{ss}er als \\
|
$>$ & gr\"osser als \\
|
||||||
$==$ & gleich \\
|
$==$ & gleich \\
|
||||||
$>=$ & gr\"o\{ss}er oder gleich\\
|
$>=$ & gr\"osser oder gleich \\
|
||||||
$<=$ & kleiner oder gleich\\
|
$<=$ & kleiner oder gleich \\
|
||||||
$\sim=$ & ungleich\\
|
$\sim=$ & ungleich\\
|
||||||
\hline
|
\hline
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
@ -725,13 +764,12 @@
|
|||||||
\end{table}
|
\end{table}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\subsection{Logical operators}
|
|
||||||
|
|
||||||
|
|
||||||
\subsection{Boolean operations}
|
\begin{frame}[fragile]
|
||||||
\begin{frame}[fragile]{Boolean operations}{Examples}
|
\frametitle{Boolean operations}
|
||||||
\tiny
|
\framesubtitle{Beispiele}
|
||||||
\begin{lstlisting}[label=booleanListing1]
|
\tiny
|
||||||
|
\begin{lstlisting}
|
||||||
>> x = [2 0 0 5 0] & [1 0 3 2 0]
|
>> x = [2 0 0 5 0] & [1 0 3 2 0]
|
||||||
x =
|
x =
|
||||||
1 0 0 1 0
|
1 0 0 1 0
|
||||||
@ -743,33 +781,50 @@
|
|||||||
>> [2 0 0 5 0] | [1 0 3 2 0]
|
>> [2 0 0 5 0] | [1 0 3 2 0]
|
||||||
ans =
|
ans =
|
||||||
1 0 1 1 0
|
1 0 1 1 0
|
||||||
\end{lstlisting}
|
\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{frame}
|
\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}
|
\end{document}
|
||||||
|
Reference in New Issue
Block a user