From 52a67a6466a4bc10f809f1fb68e2db5830c05f64 Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Fri, 11 Dec 2015 13:19:52 +0000
Subject: Finish first version report practical 2

Some changes were made to the code and the Makefile to clean up, make it
more in line with the algorithm as described in the report, etc. No
significant changes.
---
 Practical2/report/implementation.tex | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Practical2/report/implementation.tex

(limited to 'Practical2/report/implementation.tex')

diff --git a/Practical2/report/implementation.tex b/Practical2/report/implementation.tex
new file mode 100644
index 0000000..cc8a940
--- /dev/null
+++ b/Practical2/report/implementation.tex
@@ -0,0 +1,19 @@
+\section{Implementation}
+\label{sec:implementation}
+
+A C implementation accompanies this report. The $\PR$ function is implemented in $\pazocal O(1)$ in \mintinline{c}{round_profit}, but is not shown here for the sake of brevity.
+
+The implementation of the $\PP$ function, \mintinline{c}{maximum_profit}, follows the flow of \autoref{alg:maximum-profit-optimised}. However, it was easier to take the optimisation of \autoref{lem:divide-by-5} out of this function and apply it when reading in the input sequence.
+
+\inputminted[fontsize=\footnotesize,linenos,firstline=17,lastline=48]{c}{../checkout.c}
+
+In the \mintinline{c}{main} function we see how \autoref{lem:divide-by-5} can be applied. In the last line we also see how the minimal sum may be computed from the maximum profit.
+
+\inputminted[fontsize=\footnotesize,linenos,firstline=50,lastline=67]{c}{../checkout.c}
+
+\subsection{Compilation}
+\label{sec:implementation:compilation}
+Optimal results are achieved with \texttt{clang}, which is on average $25\%$ faster than \texttt{gcc}. In any case, the \texttt{-Ofast} flag should be used. It speeds up the program with a factor $4$ in the case of \texttt{clang} and a factor $3$ in the case of \texttt{gcc}.
+
+A Makefile accompanies the C code. If you don't have \texttt{clang} installed, you should install it. If you don't want to install it, use \mintinline{bash}{make CC=gcc}.
+
-- 
cgit v1.2.3

