Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am considering converting a C++03 math library to C++14 as a side project to learn C++14 and I examined Eigen and Blaze. Eigen's code size seems to be a fraction of Blaze, even though their functionalities are similar. Eigen also has some design documents while Blaze has papers but not much more. It seems I will try my hands on Eigen library for now. It is amazing that a couple of people could do in a few years; Blaze has hundred of thousands of lines of code.


If you are interested in C++14 then you are "looking to the future" as it were, in which case I would suggest Eigen. Why? One word: tensors. Eigen has already a quite usable tensor implementation, whereas as far as I can descry Blaze has no plans in that direction. Tensors show up everywhere in scientific computing. They are incredibly useful. For this reason (along with several others, which I can elaborate on if you are interested) I feel like Eigen will become the Numpy of C++ numerical array software in the future.


Eigen is header only and heavily templated, which certainly keeps the source down.

However, SLOC is a poor metric for the quality of a codebase, especially scientific ones. I've certainly found many instances where longer line counts are more performant, for instance with hand-unrolling loops (very rare edge case, not suggesting doing this as a rule!).

Unless you intend to become involved in development of the library, I see no reason you would care about the lines of code. Even at that point, design philosophy, features, etc. are more likely to be major factors in your choice.

FYI: Computational Scientist here. I am neither affiliated with Blaze nor Eigen.


I'd say lines of code does matter if the set of functionality is the same, i'd wager that, if you have the same functionality in less lines of code, generally it's easier to verify that it's correct + avoid daft bugs.

.. Unless it's written in a completely uncomprehensible way of course (such as some meta c++ stuff), but in languages with good metaprogramming.


Scientific software should absolutely, always be verified through regression and unit tests. Anything less is non-negotiable.

In a decade of work in hpc and computational science, I have very seldom found looking at the code to be a useful tool for either verification or debugging.

Instead, use the scientific method: hypothesis testing by constructing simple examples with known analytic solutions and using that for clues as to where the real problem lies.


Scientific software should absolutely, always be verified through regression and unit tests. Anything less is non-negotiable.

I like your world. Let's live there. :)


I agree with Arcanus; lines of code isn't a good measurement here. It's not uncommon for high performance math and science libraries to have specialized code to handle a lot of different cases the fastest way possible, or the most accurate way possible, etc. and some libraries are even able to switch between them heuristically based on the data they're being used on.

A common example is matrix multiply. For smaller matrices it's faster to use naive O(n^3) multiply because of the large constant factor with Strassen's algorithm. At some point n^3 will dominate the constant factor, and Strassen's becomes better. To get the best performance in all cases, both algorithms need to be implemented, which increases the code size.


Take a look at Armadillo as well. I did the same thing about a year ago, and looked at all of them. In the end, Armadillo made writing things very easy. Of course, I was really only focused on matrix multiplication, so you may have different requirements.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: