R9484/homework2ab9b8d709a7cmaster
README.md
- How to run 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)
Example
In homework2/build/src/:
./main pi write 8 comma
In homework2/src/:
python3 plotting.py out.csv
- 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.
Answer to Exercise 5.1: Evaluate the previous global complexity of your program.
From the main.cc file, we can observe that we execute 1x the method compute and 1x the method print_obj.dump(). The first one has a complexity of O(n) and the second has a complexity of O(n^2/f) in the first implementation of the code and O(n/f) in the second.
T(n) = O(n)+ O(n^2/f)
Answer to Exercise 5.4: Evaluate the new global complexity of your program.
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.