Lecturer: Sarah Boutle
Hours Equivalent Credit: 12 (4 x 1hour lectures and 4x2hr tutorials)
Assessment: Continuous Assessment
This course includes four lab sessions based in Glasgow which students will need to attend in person.
This course has priority booking for Particle Physics students. Please refer to the timetable and visit the My.SUPA course area for more information.
Programming is used more and more in scientific research to analyse data and simulate nature. Just as in lab research, results when running a software must be reproducible. Instead of writing the same code twice for different applications, only one code should be written and used by both applications. Software should also be easily extended to allow the research to answer new questions that the scientist did not have when the study began. C++ is the programming language that proved most useful for the scientific world, as it satisfies these features, is versatile and is very fast. Furthermore, the same code can be used on different operating systems, once it is compiled again there. To illustrate how useful C++ is, two thirds of the software that powers a smart phone is written in C++!
This course introduces C++ via four pairs of lecture and computer lab. The computer lab gives you access to a Linux environment with C++ compiler and an Emacs or Vim text editors. As it sometimes slows when many people connect at the same time, you are encouraged to bring your own laptop with Linux or Mac OS to work directly in your day to day work environment, if available.
The topics covered are the basic C++ that needs to get you going in your research. However, object-oriented notions, such as classes and inheritance, will not be covered in this introductory C++. The topics covered include: basic C++ syntax; standard C++ data types (bool, float, char, etc); standard C++ streams (cout, cin, error, etc); standard C++ operators (==, &&, %, etc); conditionals and loops (if, for, while, switch, case, etc); standard templated library types (string, vector, map, list, stringstream, etc); pointers and references; functions; overloading functions; passing argument to a function by reference; templated functions; how to compile your code as an executable or a shared library to be used by another piece of code; how to convert on data type to another data type; how to compute the time it takes to run your code; how to pass arguments at the command line.