Repository for homeworks of SP4E

Lars B.

Bertil T.

# Recent Commits

Commit | Author | Details | Committed | ||||
---|---|---|---|---|---|---|---|

5c87a815ab81 | • trottet | edit ReadMe.md | Jan 15 | ||||

fc2fff085f76 | blatny | added clarifying comment | Jan 13 | ||||

0a44658a05a2 | blatny | combine part 1 and 2 + comments | Jan 13 | ||||

7b30a9aeb08c | • trottet | Changes : READ-ME: answers PyPart: finished | Jan 13 | ||||

cbdfd81f38b1 | • trottet | PyBind finalization : Compile but error at running time | Jan 10 | ||||

e673a1031673 | • trottet | PyBind: add overloading compile but SegFault(CoreDumped) | Jan 10 | ||||

2fc6aa7e2486 | • trottet | PyBind : Exercise 2, Question 2 : handle types with shared_ptr<> Finalize… | Jan 10 | ||||

1dba420ccc03 | • trottet | Bindings, still a problems to figure for overload | Jan 10 | ||||

94c65adc61a4 | blatny | updated README | Jan 3 | ||||

6e71622f12cb | blatny | finished second part | Jan 3 | ||||

1f88c2ffb32e | blatny | almost finished Exercise 6 | Jan 3 | ||||

925a5a2e9403 | blatny | added temp workaround such that c++ generates same G as in python | Jan 2 | ||||

762ac192e8b1 | blatny | finished Exercise 4 and 5 | Jan 2 | ||||

d79b8ee056f1 | blatny | added README and description | Jan 2 | ||||

eae5be0ca799 | blatny | continuing on pypart.cc - commented out what does not compile | Jan 2 |

# README.md

## SP4E Homeworks

Students:

- Lars B.
- Bertil T.

In this repository, we will keep all homeworks for SP4E

### Homework 1

See folder named *hw1-conjugate-gradient*.

- Requirements

- Numpy
- Scipy
- Matplotlib
- Argparse

The code as been tested with Python 3.

##### Usage

Run the *main_minimize.py* with the following arguments:

- -A < matrix elements in row major order >
- -b < vector elements >
- -x0 < initial guess elements >
- -method < CG-scipy or CG-ours >
- -plot < True or False >

##### Example

The following command will run the program with the coefficients given in Exercise 1:

python3 main_minimize.py -A 8 0 2 6 -b 0 1 -x0 4 4 -method CG-scipy -plot True

NB: Note that the quadratic function in Exercise 1 is implemented with a multiplicative factor 1/2 in order to be consistent with Exercise 2.

The following command will run the program with a 2x2 s.p.d. matrix A and 2-dim vector b using our self-implemented conjugate gradient method for solving the LSE Ax=b:

python3 main_minimize.py -A 3 0 0 4 -b 4 5 -x0 12 12 -plot True -method CG-ours

NB: Note that A must be s.p.d. in order for the conjugate gradient method to correctly solve Ax=b. Thus, the matrix A in Exercise 1 should not be used to compare the Scipy version (CG-scipy) againts our version (CG-ours). In the output of Exercise 1, you will see that it does not solve the LSE Ax=b (i.e., the residual outputted is high).

NB: Plotting can only be accomplished in 1D (A and b are both scalars) or 2D (A is a 2x2 matrix and b is a 2-dim vector) as it is not possible to plot higher dimensional problems in a way that makes sense.

### Homework 2

See the **homework2/** folder and the instructions within its own README file.

### Homework 3

See the **hw3-heat-fft/** folder and the instructions within its own README file.

### Homework 4

See the **hw4-pybind/** folder and the instructions within its own README file.