DEV Community

Gianluca Bianco
Gianluca Bianco

Posted on

A C++ algorithm to compute the coefficients of a function development in a spherical harmonics convergent series

Hi guys, I am particle physics PhD student passionate about coding. I like to implement small physical and mathematical models in different programming languages, in order to train myself.

Now I want to show you a small project I recently finished, in which I performed a C++ main algorithm to compute the coefficients of a function development in a spherical harmonics convergent series.

All the algorithms (included integrals and derivatives) have been created from scratch (in fact the derivative doesn't work 100% well at higher orders, lol).
Hope you like it and if you have suggestions about how to improve it let me know (don't forget to leave a star on GitHub, thanks).

GitHub repository: https://github.com/JustWhit3/SAFD-algorithm

Top comments (4)

Collapse
 
miguelmj profile image
MiguelMJ • Edited

Hey, it looks really cool, it's clear that you've dedicated real time and effort to it, even the code is commented. I love seeing this kind of stuff done in C++, so I'm already loving it, but I'll try to give you some useful feedback:

  • Most people (starting with me) are not familiar with what this SAF functions are, what do they describe, explain or what they're useful for. So, unless you target your code to very specific coders, your README would benefit from a more top-down (on abstraction) structure:
    • Summary or link to an explanation of what Spherical Armonics Function are (I still have no clue) try to reduce to the minimum the amount of math language here. If there is something graphical you can show (even if it is a wikimedia image) put it here to make it easier to understand.
    • The how-to-use: at least one use case example of the algorithm/program/library, better if with reproducible input and output (don't put it at the end!).
    • Installation.
    • More in-depth explanation.

It is the usual information flow in good READMEs (go from practical to theorical). The contents you have now are at least very similar, so this means just rearrange some information.

  • As you have the good habit of documenting your code, and also are not afraid of using third party tools (like valgrind or doctest) I would recommend you trying Doxygen to generate a documentation from the code. Also you can put there the heavy algorithm explanation; there is nothing wrong with putting it in the README but generally makes more sense in a separate document.

If you look to other scientific-type repositories, most are as I more or less described here. This one for example has that practical-to-theorical, show-to-explain structure and a separate document for in-depth stuff.

I hope you find it useful, all these are just suggestions. Good work and keep it up!

Edit: After reading a bit about this functions I see it's a very specific topic, so take my advice with a grain of salt, because it's better suited for a more general-public code.

Collapse
 
justwhit3 profile image
Gianluca Bianco

Hi @miguelmj you're suggestions are gold for me! Thank you very much for all this and of course don't hesitate on telling me other stuff you think should be changed. As you, I am passionate about coding and on the other hand I love learning new stuff so all these things you said me are really important. Of course I will improve my documentation as soon as possible; since many arguments require pages and pages of explanation I could put hyperlink to other pages with more accurate information, just in case a curious reader would like to deepen into them!

I also seen some of your projects on GitHub and I can say you are a real C++ master! It's a pleasure to get suggestions from you!

Collapse
 
miguelmj profile image
MiguelMJ

Btw stalking your repos and website, I've seen you put a link to a StackOverflow profile that is broken, maybe you should check it. Cheers!

Collapse
 
justwhit3 profile image
Gianluca Bianco

Yes, thanks also for this! I put the wrong link on my website, ops! Now I fixed it