FYSS5120 Efficient Numerical Programming
Hi, I'm Vesa Apaja, and I'll be lecturing this course starting 3. September 2024.
My office is in JYU Nanoscience Center YN223, and my email is vesa.apaja at jyu.fi
I'm a Linux guy with very limited experience on Microsoft or Apple products (historical reason,
I didn't have any money when I got to this business).
I've taken a couple of courses on C++ (ancient C++, before there was any standard), none on Python or Julia.
Given the circumstances, I had to self-learn programming. Some think I did learn something,
so the first programming language I was teaching was C, following the legendary The C programming language by
Dennis Ritchie and Brian Kernighan.
Despite of little or no tutoring, during the past 30+ years I've written way too many lines of code.
These lectures and demos are intended to give you enough confidence to use Python, Julia or C++
in the challenges you face during your studies and ever after. Learning programming is not much different
to learning a spoken language: start programming and make mistakes.
Fortunately, it's very hard to upset a computer.
This course covers only programming numerics.
The attribute "efficient" was added for sales purposes by someone else. People used to
call numerics "number crunching", but we've come to value also the human time spent in coding
- mainly because coders are well paid. So I've been told. Fast coding is were Python excels.
Sometimes you need to spend hours to push your code to the speed that will quarantee
some output in a reasonable time. C++ stands in that corner. Julia is somewhere in between.
If I could learn programming, so can you.
Welcome!
Structure
- 4 cr, evaluation accepted/rejected
- 14 Lectures at 12:15-14:00 on Tuesdays and Thursdays in FYS2 (YFL343)
- First lecture 3. September 2024
- Lectures in Zoom (link)
- 6 Demo sessions on Thursdays 10:15-12:00
- First demo session 12. September 2023 in FYS5 (YFL226)
Requirements
- Accepted solutions to programming assignments (demos 2-6)
Demo 1 solved in the first demo session.
Demos 2-6 will be tutored in demo sessions.
- No Exam
- For the programming tasks (call them demos for short) you need a computer.
A laptop will do.
Two options:
- Option 1: Install the necessary programs to your computer.
You need at least
- A recent Python (3.6 or newer, install NumPy, Scipy etc.)
- A recent C++ compiler, GSL and armadillo libraries.
- Option 2: For JYU students;
If you don’t want to install programs on your own computer, log in the Physics Department server
kone.phys.jyu.fi using JYU user name and password. Use the environment modules
- python/3.10.6
- julia/1.8.0
- gcc/12.2.0
- boost/1.80.0
- mpi/openmpi-x86_64
- pmi/pmix-x86_64
For example, the command "ml add python" gives you the Python 3.10.6 interpreter.
Material
-
Lecture notes (all.pdf)
The lecture notes contain mostly Python, Julia, and C++. The C++ portion
has shrunk to give way to Python.
Lecture timetable:
- Tuesday 3.9.: historical notes about programming languages
- Thursday 5.9.: Lists, list comprehensions, sets, dictionaries, and NumPy sorting
- Tuesday 10.9.: Advanced unpacking, decorators (dataclass decorator, cache decorator),
automatic testing with doctest. Try to get to generators.
- Thursday 12.9.: Basic class structure, inheritance. Demo: talked a bit about NumPy broadcasting and einsum.
- Tuesday 17.9.: Initialization on random number generators, serial and parallel code
- Thursday 21.9.: match-case construct and a side effect, debugging segmentation fault,
- Tuesday 24.9.: @property in Python, Python in ASE (Atomic Simulation Environment),
BLAS in OpenBLAS and MKL, MKL optimization for AMD CPU's.
- Thursday 26.9.: Machine learning
- Tuesday 1.10.: More machine learning and started gaussian process regression GPR.
- Thursday 3.10.: More GPR, playing with autograd and jax.
- Programming tasks (demos)
Demo 1 will be "solved" in the first demo session.
Demos 2-6 will be tutored in demo sessions, but I'll leave some programming for you, too.
- Sample code
Extra material