loiseaujc
Joined 1 year ago
Joined 1 year ago
Jacobi and Gauss-Seidel wouldn't be solvers I'd even consider for a real problem. But they are simple enough that anyone with a basic understanding of linear algebra and programming can follow along. But much research requires me to run simulations on thousands (if not hundreds of thousands) of cores, and there, off-the-shelf solver implementations will often not cut it.
This is the 4th (3rd?) post in this Jacobi series. Gauss-Seidel and Jacobi are sufficiently simple that very little math is needed to understand how they work. But they also offer a very nice opportunity to illustrate the interplay of mathematical algorithms and actual hardware implementation as well as gradually introducing some elements of performance engineering.
To give you idea of where we're going: after discussing SOR and make connections with other fields of applied math, we'll eventually get to multigrid solvers. And Jacobi and Gauss-Seidel play a really important role in this. Multigrid are also some of the best iterative solvers possible for such discretized elliptic operators. But I can only blog now and then, and I want to take one step at a time so that upper-level undergradute in either math or computer science can follow along.
Pedagogy is indeed the point. This is the 4th (3rd?) post in this Jacobi series. Gauss-Seidel and Jacobi are sufficiently simple that very little math is needed to understand how they work. But they also offer a very nice opportunity to illustrate the interplay of mathematical algorithms and actual hardware implementation as well as gradually introducing some elements of performance engineering.
To give you idea of where we're going: after discussing SOR and make connections with other fields of applied math, we'll eventually get to multigrid solvers. And Jacobi and Gauss-Seidel play a really important role in this. Multigrid are also some of the best iterative solvers possible for such discretized elliptic operators. But I can only blog now and then, and I want to take one step at a time so that upper-level undergradute in either math or computer science can follow along.
In any case, the idea behind this series on Jacobi (this is like the 4th post I believe) is to help students (and people interested in scientific computing in general) get what actually matters computationally and lift the hood to get some understanding of the interplay between such algorithms and their actual implementation on hardware.
> This is a big red flag. If they have little background in programming, teach good standards of Python.
That is a big issue, I'll admit it. And actually, in my Uni, I am a very strong proponent of making an intro to programming class mandatory before even being able to enroll in any other engineering classes. Unfortunately, I don't see this happening anytime soon mostly because the higher-ups have a distorted view of what programming actually is. And I believe it is the same in many French universities. May-be different elsewhere, I don't know, but in the mean time I have to make do with what I have.
> Otherwise they will get worst patterns, and think that GOTO is the preferred way of coding.
People keep on referring to `goto`. But that is a construct that has been considered bad since the Fortran 1990 standard, 35 years ago. Fair enough, there are plenty of legacy codes using it. Just like there are plenty of C code written 35 years which are just terrible by today standard. Modern Fortran (and by modern I mean anything following 2003 standard and more recent) does not use `goto`. And academics writing Fortran code today do not use `goto`, nor do they teach it.
> If you think why a lot of academic code looks like mess, one of the reason is using archaic tools and techniques as a standard.
Again, I think this is a very distorted view. When you need to run your code on 1000+ CPU, which is what I and my colleagues do, you better make sure your code makes use of all the most recent good practices and use industry-standard tooling not to waste CPU hours because of a stupid bug or what not.
I'm not dismissing Julia. Actually, the first lines of my conclusions are
> In the end, when it comes to teaching the basics of numerical linear algebra, Python and Fortran are not that different. And in that regard, neither is Julia which I really like as well.
I feel like people got the impression that I'm saying they *should* use Fortran for teaching. That ain't the point, but maybe I did not convey it as clearly as I would have like. The point is : a programming language with strong typing, clear begin/end constructs, ensuring inputs to a function cannot be accidentally modified (otherwise it has to be a subroutine), etc actually makes it easier for the students to effectively *learn* computational thinking rather than having to battle with syntax errors and strange intricacies of a general-purpose language. Fortran is just an example which turns out to be historically related to number crunching.
Unicode support and greek letters sure can be useful when presenting code snippets in your slides, but it essentially is syntactic sugar coating. And, unfortunately, many students have no idea how to spell greek letters (e.g. \to for \tau, \fi for \phi, etc) and just end-up loosing time on aesthetic details rather than focusing on the learning objective.
Finally, you may not know it but Fortran does have a package manager. Check out fpm (https://github.com/fortran-lang/fpm). It basically is just like Pkg for Julia, also using a toml manifest, can be installed via conda, makes sure things are reproducible across compilers and platforms, etc.