X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=christiaan%2Fdotproduct.lhs;fp=christiaan%2Fdotproduct.lhs;h=4a150c9e08696181132408e470de6c59d9e5818a;hb=a6db20a6d9cfe457b5deb643932813b921a04d47;hp=0000000000000000000000000000000000000000;hpb=0c004e8c0dff6f9a4140519c8b31410f9b0c8242;p=matthijs%2Fmaster-project%2Ffinal-presentation.git diff --git a/christiaan/dotproduct.lhs b/christiaan/dotproduct.lhs new file mode 100644 index 0000000..4a150c9 --- /dev/null +++ b/christiaan/dotproduct.lhs @@ -0,0 +1,56 @@ +%include talk.fmt +\subsection{Dot Product} +\begin{frame} + \frametitle{Dot Product} + \[ + y = \overrightarrow x \bullet \overrightarrow h + \] +\end{frame} + +\begin{frame} + \frametitle{Dot Product} + \[ + y = \overrightarrow x \bullet \overrightarrow h + \] + \[ + \overrightarrow x \bullet \overrightarrow h = \sum\nolimits_{i = 1}^n {a_1 \cdot b_1 + a_2 \cdot b_2 + \ldots + a_n \cdot b_n } + \] +\end{frame} + +\begin{frame} + \frametitle{Dot Product} + \begin{itemize} + \item Two steps to define: \\ + \[ + \overrightarrow x \bullet \overrightarrow h = \sum\nolimits_{i = 1}^n {a_1 \cdot b_1 + a_2 \cdot b_2 + \ldots + a_n \cdot b_n } + \] + \begin{itemize} + \item \emph{Pairwise Multiplication}: \\ + \begin{verbatim} + zipwith (*) xs hs = + < x0*h0, x1*h1, x(n-1)*h(n-1)> + \end{verbatim} + \item \emph{Summation}: \\ + \begin{verbatim} + foldl (+) 0 zs = + (..((0+z0)+z1)+..+z(n-1)) + \end{verbatim} + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame} + \frametitle{Dot Product} + \begin{itemize} + \item Two steps to define: \\ + \[ + \overrightarrow x \bullet \overrightarrow h = \sum\nolimits_{i = 1}^n {a_1 \cdot b_1 + a_2 \cdot b_2 + \ldots + a_n \cdot b_n } + \] + \begin{itemize} + \item \emph{Combine the two}: \\ + \begin{verbatim} + xs ** hs = foldl (+) 0 (zipWith (*) xs hs) + \end{verbatim} + \end{itemize} + \end{itemize} +\end{frame} \ No newline at end of file