README.md 9.23 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
# Scientific Programming with C++
Praetorius, Simon's avatar
Praetorius, Simon committed
2

Praetorius, Simon's avatar
Praetorius, Simon committed
3
4
5
6
7
8
9
10
11
12
13
## Lecture notes

| Topic                                  | Download                 |
|----------------------------------------|--------------------------|
| Scientific Programming with C++        | [lecture.pdf][]          |

[lecture.pdf]: https://gitlab.mn.tu-dresden.de/teaching/scprog/so2021/-/jobs/artifacts/master/raw/lecture/lecture.pdf?job=build


## Exercise sheets

14
| Week | Topic                                  | Link            |
Praetorius, Simon's avatar
Praetorius, Simon committed
15
|------|----------------------------------------|-----------------|
16
17
| 01   | Overview and Motivation for the Course | [sheet1.md][]   |
| 02   | Basic Syntax and Types                 | [sheet2.md][]   |
Praetorius, Simon's avatar
Praetorius, Simon committed
18

19
20
[sheet1.md]: https://gitlab.mn.tu-dresden.de/teaching/scprog/so2021/-/blob/master/exercises/sheet1.md
[sheet2.md]: https://gitlab.mn.tu-dresden.de/teaching/scprog/so2021/-/blob/master/exercises/sheet2.md
Praetorius, Simon's avatar
Praetorius, Simon committed
21
22
23
24


## General information

Praetorius, Simon's avatar
Praetorius, Simon committed
25
26
27
28
29
*Summary of the lecture*

*general information about the structure of lecture and tutorial*


Praetorius, Simon's avatar
Praetorius, Simon committed
30
In this module SCPROG the exercises and projects will be submitted online into a version
Praetorius, Simon's avatar
Praetorius, Simon committed
31
control system [Git](https://git-scm.com/) hosted at the MatNat [GitLab](https://gitlab.mn.tu-dresden.de)
Praetorius, Simon's avatar
Praetorius, Simon committed
32
platform, which is a web-based Git repository manager similar to [GitHub](https://github.com)
Praetorius, Simon's avatar
Praetorius, Simon committed
33
34
and [Bitbucket](https://bitbucket.org).

Praetorius, Simon's avatar
Praetorius, Simon committed
35
36
Handing in solutions to exercises and projects digitally on such a platform is a
good way of learning and training collaborative coding, which is commonplace in
Praetorius, Simon's avatar
Praetorius, Simon committed
37
38
Scientific Computing research groups.

Praetorius, Simon's avatar
Praetorius, Simon committed
39
Additionally to the learning effect, you can collect points for submitted exercises
Praetorius, Simon's avatar
Praetorius, Simon committed
40
that may eventually lead to an improvement in you final exam by at most a grade 0.3. To
Praetorius, Simon's avatar
Praetorius, Simon committed
41
reach this bonus, you have to gain 66% of the possible exercise points (max. = 100).
Praetorius, Simon's avatar
Praetorius, Simon committed
42

Praetorius, Simon's avatar
Praetorius, Simon committed
43
In order to allow fast correction and evaluation of submitted solutions, we require
Praetorius, Simon's avatar
Praetorius, Simon committed
44
a predefined structure of the repositories and coding styles to be followed. Not
Praetorius, Simon's avatar
Praetorius, Simon committed
45
following these rules for repositories may result in your solution not being reviewed.
Praetorius, Simon's avatar
Praetorius, Simon committed
46
47
48
49
50
51
You will then have to reformat it and submit again. Not following the style guidelines
may result in point deduction, with the amount of points depending on the impact your
style could have on actual collaborative projects.

# Your Repository on GitLab
## Account
Praetorius, Simon's avatar
Praetorius, Simon committed
52
In the first tutorial we will create an account on the local GitLab platform,
Praetorius, Simon's avatar
Praetorius, Simon committed
53
54
using the ZIH-Login (s...-number) for the account user name associated to your TU-Dresden
email address. This ensures that you will get credit for your submissions.
Praetorius, Simon's avatar
Praetorius, Simon committed
55
56

## Project Name
57
Please form groups of up to two members and exchange contact details so you can find
Praetorius, Simon's avatar
Praetorius, Simon committed
58
each other on GitLab. One of you should create a *private* (!) project, and invite the rest
59
60
of the group. The name of your project is `scprog-Name1Name2`, where `Name1`
is the last name of the first student, `Name2` that of the second student. These
Praetorius, Simon's avatar
Praetorius, Simon committed
61
62
63
64
65
66
67
68
69
70
names should be sorted alphabetically. If your lineup changes for any reason during the
course of the semester, please create a new project that reflects this and inform your
tutors.

## Directory Structure
Your repository should consist of two levels of directories, one for the exercise sheets and
one for the individual exercises. This results in a tree structure like this:

```
sheet1
Praetorius, Simon's avatar
Praetorius, Simon committed
71
72
73
74
75
76
77
78
79
 +-- exercise1
 |    +-- main.cc
 |    +-- solution.txt
 |    \-- <header and source files>
 |
 +-- exercise2
 |    \-- <files as above>
 |
 \-- (...)
Praetorius, Simon's avatar
Praetorius, Simon committed
80

Praetorius, Simon's avatar
Praetorius, Simon committed
81
sheet2
Praetorius, Simon's avatar
Praetorius, Simon committed
82
83
84
 +-- exercise1
 +-- exercise2
 \-- (...)
Praetorius, Simon's avatar
Praetorius, Simon committed
85

Praetorius, Simon's avatar
Praetorius, Simon committed
86
(...)
Praetorius, Simon's avatar
Praetorius, Simon committed
87
88
89
90
91
92
```

You are free to name and structure your C++ files in any way you like, but there
should always be a file named `main.cc` that is a sample application of your implemented
classes. Often the content is given in the exercise, if it isn’t you are free to choose
sensible test cases yourselves. Make sure that this file `main.cc` can be compiled with
Praetorius, Simon's avatar
Praetorius, Simon committed
93
the command given in the lecture, or alternatively provide a [MakeFile](http://www.c-howto.de/tutorial/makefiles/)
Praetorius, Simon's avatar
Praetorius, Simon committed
94
or [CMakeLists.txt](https://cmake.org/cmake/help/latest/) that builds the exercise.
Praetorius, Simon's avatar
Praetorius, Simon committed
95
96
97

The file `solution.txt` is meant for the output of your `main.cc` and for answering
questions that appear in the exercises. If an exercise is of theoretical nature and doesn’t
Praetorius, Simon's avatar
Praetorius, Simon committed
98
99
100
include actual coding, this is the only file you have to submit. Optionally you can
submit a [Markdown](https://docs.gitlab.com/ee/user/markdown.html) file `solution.md`
instead. This allows basic formatting of the text.
Praetorius, Simon's avatar
Praetorius, Simon committed
101
102

## Access to the Repository
103
104
Please give your tutor @spraetor write access (at least Reporter status) to your project so that
your submissions can be graded.
Praetorius, Simon's avatar
Praetorius, Simon committed
105

Praetorius, Simon's avatar
Praetorius, Simon committed
106
# Submission of Exercises
Praetorius, Simon's avatar
Praetorius, Simon committed
107
108
109
110
On each exercise sheet some exercises are marked for submission with in sum 10 possible exercise points.
You have approximately two weeks for each of these exercises, where the final date is written
next to the exercise. In order to get your solutions reviewed, it has to be committed to your
GitLab repository following the procedure:
Praetorius, Simon's avatar
Praetorius, Simon committed
111
112
113
114

1. For each exercise sheet create a new branch called `sheetX` where `X` is the number of
   the sheet.
2. Create the new directory following the directory structure as above
Praetorius, Simon's avatar
Praetorius, Simon committed
115
3. Commit your solutions to the branch
Praetorius, Simon's avatar
Praetorius, Simon committed
116
117
4. Create a merge request to your master branch

Praetorius, Simon's avatar
Praetorius, Simon committed
118
After final review of your submission (and maybe inclusion of your corrections)
Praetorius, Simon's avatar
Praetorius, Simon committed
119
120
you get a comment in the MergeRequest section of GitLab and a :thumbsup:. This allows you to merge
your branch into your `master` branch.
Praetorius, Simon's avatar
Praetorius, Simon committed
121

Praetorius, Simon's avatar
Praetorius, Simon committed
122

Praetorius, Simon's avatar
Praetorius, Simon committed
123
124
125
126
127
128
129
130
131
132
133
# Style Guidelines
All programs you submit should follow basic programming rules like the following:

- **Formatting**
  - Put each instruction on a separate line (two lines if it is very large)
  - Use spaces to separate variable names, functions and operators
  - Indent your lines to visually mark different lines belonging to different scopes
- **Variable names**
  - The name should reflect the purpose of the variable
  - Variable names start with a lowercase letter, types with an uppercase letter
  - The rest of the name format for identifiers is up to you
Praetorius, Simon's avatar
Praetorius, Simon committed
134
  - Simple counting integers and similar variables are exceptions
Praetorius, Simon's avatar
Praetorius, Simon committed
135
136
137
138
- **Comments**
  - Comments allow others to understand your intentions
  - Tutors can only give you points if they understand what you were trying to do
  - *Guideline:* one comment per class, per function, per algorithm subtask, per tricky or "exotic" source line
Praetorius, Simon's avatar
Praetorius, Simon committed
139
  - Don't comment to much either, this may visually drown the actual code or diverge from what is actually coded (!)
Praetorius, Simon's avatar
Praetorius, Simon committed
140
141
142
143
  - Leave out trivial comments ("This is the constructor")
- **Language constructs**
  - You may use any construct you want, even if it has not yet been introduced in the lecture
  - Avoid constructs that have been superseded by better alternatives in the lecture
Praetorius, Simon's avatar
Praetorius, Simon committed
144
  - Declare variables and references as `const` where it is possible
Praetorius, Simon's avatar
Praetorius, Simon committed
145
  - Separate interface and implementation by correctly using public and private
Praetorius, Simon's avatar
Praetorius, Simon committed
146
  - Use smart pointers instead of raw pointers once the lecture has introduced them
Praetorius, Simon's avatar
Praetorius, Simon committed
147

Praetorius, Simon's avatar
Praetorius, Simon committed
148
Optionally, see [Google C++ Style Guide](http://google.github.io/styleguide/cppguide.html) for
Praetorius, Simon's avatar
Praetorius, Simon committed
149
150
more rules and guidelines on the coding style. Also, see the
[C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md)
Praetorius, Simon's avatar
Praetorius, Simon committed
151
152
153
154
155
for a comprehensive list of best practice programming rules for C++.

# More reading
Online references and literature useful for completing the exercises are listed below:

Praetorius, Simon's avatar
Praetorius, Simon committed
156
157
158
159
- **Online-References:**
  - [cppreference.com](http://en.cppreference.com), [BLAS](http://www.netlib.org/blas),
    [LAPACK](http://www.netlib.org/lapack/), [DUNE](https://www.dune-project.org/doxygen/),
    [Git](https://git-scm.com/docs), [Boost](https://www.boost.org/doc/libs/1_71_0/),
Praetorius, Simon's avatar
Praetorius, Simon committed
160
    [CMake](https://cmake.org/cmake/help/latest/)
Praetorius, Simon's avatar
Praetorius, Simon committed
161
- **Cheat-sheets:**
Praetorius, Simon's avatar
Praetorius, Simon committed
162
  - [Divhints](https://devhints.io/), [Git](https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf),
Praetorius, Simon's avatar
Praetorius, Simon committed
163
    [Linux Command Line](https://appletree.or.kr/quick_reference_cards/Unix-Linux/Linux%20Command%20Line%20Cheat%20Sheet.pdf)
Praetorius, Simon's avatar
Praetorius, Simon committed
164
- **Tutorials:**
Praetorius, Simon's avatar
Praetorius, Simon committed
165
  - [MTL4](http://old.simunova.com/docs/mtl4/html/tutorial.html), [Git](https://git-scm.com/book/en/v2)
Praetorius, Simon's avatar
Praetorius, Simon committed
166
- **Compiler:**
Praetorius, Simon's avatar
Praetorius, Simon committed
167
  - [GCC](https://gcc.gnu.org/), [Clang](http://clang.llvm.org/), [Intel Icc](https://software.intel.com/en-us/c-compilers)
Praetorius, Simon's avatar
Praetorius, Simon committed
168
169
- **Books:**
  - Discovering Modern C++: An Intensive Course for Scientists, Engineers, and Programmers, Peter Gottschling, 2015:
Praetorius, Simon's avatar
Praetorius, Simon committed
170
    [slub](http://katalogbeta.slub-dresden.de/id/0017278767/#detail), [online](http://proquest.tech.safaribooksonline.de/9780134383682)
Praetorius, Simon's avatar
Praetorius, Simon committed
171
  - *References:* Die C++ Programmiersprache (Bjarne Stroustrup),
Praetorius, Simon's avatar
Praetorius, Simon committed
172
173
    C++ Kurz & Gut (Kyle Loudon, Rainer Grimm): [slub](http://katalogbeta.slub-dresden.de/id/0012713756/#detail)
  - *Beginners:* C++ Primer (Stanley Lippman, Josee Lajoie, Barbara E. Moo): [online](http://proquest.tech.safaribooksonline.de/9780133053043)
Praetorius, Simon's avatar
Praetorius, Simon committed
174
  - *Intermediate level:* Effective Modern C++ (Scott Meyers): [slub](http://katalogbeta.slub-dresden.de/id/0013617247/#detail), [online](http://proquest.tech.safaribooksonline.de/9781491908419),
Praetorius, Simon's avatar
Praetorius, Simon committed
175
    C++ Templates: The Complete Guide (David Vandevoorde, Nicolai M. Josuttis): [online](http://proquest.tech.safaribooksonline.de/0201734842)
Praetorius, Simon's avatar
Praetorius, Simon committed
176
  - *Experts:* Modern C++ Design (Andrei Alexandrescu): [online](http://proquest.tech.safaribooksonline.de/0201704315),
Praetorius, Simon's avatar
Praetorius, Simon committed
177
    C++ Template Metaprogramming (David Abrahams, Aleksey Gurovoy): [online](http://proquest.tech.safaribooksonline.de/0321227255)