2
$\begingroup$

I'm a master student with a good Numerical analysis background. I'm going to do a master thesis in the same subject, but I need to use C++ since my advisor loves it, and I also believe it's the best programming language to have full control on what's going on in numerics.

I think I have a good background in C++, I implemented some data structure like Linked Lists but I can also code a Newton's method or stuff like that. I'm also familiar with object oriented programming , pointers, smart pointers, templates and such. I'd like to know if you have some good reference for writing scientific software in C++, or at least to write numerics in C++.

I'm aware of Numerical recipes, but as you may know, the routines they provide are not so well written (see Why not use Numerical Recipes? ) and personally I'm looking for something more focused on the C++ part, rather than the numerics. For instance, I've not found any book that teaches/explain how to write a good class for solving ODEs in C++, which is a thing I'd like to learn.

Any reference/personal opinion, whatever, is highly appreciated!

$\endgroup$
8
  • $\begingroup$ I think you should be careful to distinguish the criticism that is being made by your link and what you are asking for. That link is suggesting that the algorithms implemented are not great, especially in the age of the internet. Now they also may not be good examples of scientific programming style but that’s not what is being mentioned in the post. I also am not sure that you are going to be able to find a book on scientific software specifically for the same reason. @joni’s suggestion is probably a good bet, especially looking for recent online content. $\endgroup$ – Kyle Mandli Feb 27 at 14:21
  • 1
    $\begingroup$ I should also mention that there are a number of superb projects that are written in C++ that you may want to take a look at such as deal.ii among others. $\endgroup$ – Kyle Mandli Feb 27 at 14:24
  • 1
    $\begingroup$ It's easy to go overboard with C++ features (e.g., templates and meta-programming) which can be difficult to reason about. Over the past 30 years, I've found that keeping things clean and simple is the best policy, e.g., use pointers only when absolutely necessary. Also, if you start now, start with C++20 if possible. $\endgroup$ – Biswajit Banerjee Feb 28 at 19:12
  • $\begingroup$ Thanks @BiswajitBanerjee for your advice. In the last year I used basically C++14 only, mainly because my lectures and my book were using it, but also because things like unique_ptr are already present in C++14. Where should I learn C++20? $\endgroup$ – bobinthebox Mar 1 at 11:05
  • $\begingroup$ @KyleMandli I was aware of deal.ii, but I was looking at something more didactic, where some good practices of numerical software are explained. For instance, how one should design a poisson solver, or how one should design an ODE solver, and such $\endgroup$ – bobinthebox Mar 1 at 11:07
3
$\begingroup$

You may take a look at Peter Gottschling's Discovering Modern C++, especially chapter 7, where Mario Mulansky (one of the authors of odeint) implements a generic ODE Solver (using Runge-Kutta algorithms and C++11/14). To the best of my knowledge, the second version of the book will be published within the next months and covers C++17 and C++20.

Another useful reference could be this lecture, which I attended this semester.

$\endgroup$
2
  • $\begingroup$ Thanks, I'll have a look at that book :-) For the linked material, the only available stuff seems to be the slides, right? @joni $\endgroup$ – bobinthebox Feb 27 at 19:16
  • $\begingroup$ @bobinthebox Right, and the exercise sheets should be available, too. $\endgroup$ – joni Feb 27 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.