I am learning C/C++ for Scientific Computing and I have a question regarding the usage of scientific libraries for basic operations.

Suppose I have to write a small program in C for a bioinformatics project: for some operations I need to use matrices and very basic computations on them (LU for instance). I went through some notes online and it seems like there are different ways to declare matrices in C/C++ like [][] or by using double pointers. It is very confusing as a beginner and many say that some of these methods are not efficient.

Then I went through some examples using GSL: it seems really easy and elegant. I will probably just use the functions to declare and set matrices and to use LU decomposition. My question is then: does it make sense to use this library for such a small project? Even simpler: does it make sense to use it just to avoid the complications related to using multidimensional array in C/C++?


Of course it makes sense to use the GSL (or another library for that matter) for several reasons:

  1. Don't reinvent the wheel. The work has been done, you can spend your time on more useful things.
  2. If you do decide to implement these basic things yourself, the risk that your code will probably contain some bugs and will be slower, less memory efficient etc is quite high. Not because I think you are a lousy programmer but simply because these "established" libraries have multiple developers and large user bases in different applications (many eyes see more than two, many brains are , in general, smarter than a single one, ...)
  3. If you're interested in what's going on behind the curtains by all means read the documentation (user guide, developer's guide, design documents, ...) and even the source code. You will learn a lot ...

I don't take a position on GSL itself, these are observations valid for any "established " ( open source or commercial) library.


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.