Effective Analysis Programming 1
We give an introduction to advanced topics of C++. These include inheritance, templates, stable numerical calculations, debugging and profiling. The main focus is on rules and guidelines to write clear code and avoid common pitfalls.
Desirable Prerequisite: Basic knowledge of C/C++
- Stroustrup: "The C++ Programming Language", 3rd edition
- Sutter, Alexandrescu: "C++ Coding Standards"
- Press et al.: "Numerical Recipes", 3rd edition
- Meyers: "Effective C++" etc.
- gks-044.scc.kit.edu 126.96.36.199
- gks-246.scc.kit.edu 188.8.131.52
- Floating point arithmetic, numerical algorithms
- Coding Guidelines 1(Organization and policy, Design style, Coding style, Function) Media:Effprog.pdf
Monte Carlo method for moment of inertia
Random numbers can be used to solve complex integrals. Here, you are asked to compute the moment of inertia of a thin cylindrical shell and a cylinder, with radius R and length l. View the body as a composition of points with equal mass and sum up each point's moment of inertia .
Start with the program: File:Cylinder.cc
To get started, execute:
mkdir inertia cd inertia wget https://wiki.scc.kit.edu/gridkaschool/upload/2/2d/Cylinder.cc mv Cylinder.cc cylinder.cc g++ -o cylinder cylinder.cc ./cylinder
Create the root directory of CVS:
mkdir cvsroot cvs -d $PWD/cvsroot init
Point CVSROOT to the new directory:
export CVSROOT=<full path to cvsroot>
Import your project into CVS:
cd inertia cvs import -m "start" Inertia INITIAL start
cd cvs co -d inertiawork Inertia
cvs diff cvs status cvs commit -m"precise description" <files> cvs diff --brief cvs up cvs add cvs delete
Implement a 3D-Vector
In order to make our program more general (different bodies, different axis) we need a class for 3D vectors that can also compute the cross product.
- Complete the class implementation with the following files: File:Vector.hh,File:Vector.cc,File:Vectortest.cc
- Adapt cylinder.cc to use the new Vector class
Add the following Makefile to your project: File:Makefile.junk and rename it to Makefile.