- How to run the program
- Compile and run program with the following commands
mkdir build/ cd build cmake .. make ./src/main arg1 arg2 arg3 arg4
- arg1 can be either pi or arithmetic depending on what you want to calculate
- arg2 can be either write or print depending on if you want to write to file or print to screen
- arg3 can be either any integer representing precision of output
- arg4 can be either comma or pipe or space (anything other than comma or pipe will be interpreted as space) and represents the separator used in writing to file. When printing to screen only space is used as it does not make sense (in terms of readability) to use any other separator when printing to screen
Plotting of convergence of the pi calculation can be acccomplished by running python script plotting.py in the homework2/src/ directory as follows: python3 plotting.py filename where filename is the name of the output file (e.g., out.csv which is located in the build/ directory)
./main pi write 8 comma
or, for example,
./main arithmetic write 10 pipe
python3 plotting.py out.csv
or, for example,
python3 plotting.py out.psv
- Note that WriteSeries has been removed due to PrintSeries is now able to both print to screen and write to file. Thus no need for WriteSeries any more as all functionality is in PrintSeries. You can check out the git history if you're interested.
- Since Series, ComputePi and ComputeArithmetic are rather small classes (i.e., have simple member functions) we chose not to separate declarations and definitions into .hh and .cc file for readability. In other words, the definitions of the member functions are found in the respective .hh files.
- Answer to Exercise 2.1: What is the best way/strategy to divide the work among yourselves?
- Define the subsets of parts which can be (mostly) independent and divide them in a suitable way between each members. Work on the independent parts (1) of the same task/project (2).
(1) : To minimize overlaps/collisions ( parallel process) (2) : To be able to debug and adapt regularly the growing project and understand the problems of each others. ( iterative process)
- Brainstorm discuss and think (with+without the members) on how to solve the most complexe tasks/parts.
- Assemble and adapt each piece of the project step by step.
T(n) = O(n)+ O(n^2/f)
T(n) = O(n)+ O(n/f)
- Answer to Exercise 5.5: If you want to reduce the rounding errors over floating point operation by summing terms reversely,
- What is the best complexity you can achieve ?
T(n) = 2*O(n)
Reversing the summation order to reduce the rounding errors will not change the complexity.