Most of my programming is one-off research codes in C for my own use. I have never distributed any code to other than close collaborators. I have developed an algorithm that I am publishing in a scientific journal. I want to provide the source code and perhaps executable code in the online supplement to the article. A colleague requested that I make a generalization to the algorithm which required me to write in C++ (ack!) and which requires that I solve small dense linear systems. If I succeed in getting a user base for the algorithm it will be partly because the entry bar to using it is low (like on the floor). Potential users won't install libraries, etc. in order to use the code. I want the code to be fully stand alone and unencumbered by any license at all. I might simply write my own solver by taking something out of Golub and van Loan but I'd rather use a vanilla solver that someone else has already written if there are any out there. Suggestions appreciated. Thanks!
I would suggest to exactly duplicate the Lapack interface to the function that you need, most probably you just need
In the Fortran land, the Lapack library is such a standard, that most people simply use it and that's it, instead of providing their own implementations.
A very early mistake that many people make when getting started in scientific computing is assuming that you need to write all of your code in the same language. I think this is due largely to historical reasons, when it wasn't clear how to make compiled programs communicate with each other across even versions of the same compiler. That said, in this case, if you are going to be using C++ anyway, there are several very good C++ header-only template libraries that might fit your needs.
Since you are distributing your code for academic reasons, and you would like to embed a dense linear algebra solver into your code, I would strongly recommend that you consider Eigen. Eigen has been licensed under the Mozilla Public License and is a header-only library. This means that you can distribute Eigen with your code in source form (this does not impose any licensing restrictions on your code), and you will receive access to its general capabilities, including extremely efficient dense linear solvers. As GertVdE mentions, you have several other options.
If you want a reliable solver for systems of linear equations I would recommend FLENS. It contains an exact re-implementation of LAPACK (it even reproduces the same roundoff errors as LAPACK if a single-threaded BLAS implementation is used). This is true for all FLENS-LAPACK functions (together with the utility functions about 100 routines).
FLENS is under a BSD License and therefore allows to be incorporated into proprietary products.
FLENS is header only and if you only need a subset of FLENS I can give you a stripped-down version containing only those functions you need. FLENS comes with its own reference BLAS implementation. But optionally your users can link against optimized BLAS libraries like ATLAS, OpenBLAS or GotoBALS. For large matrices this gives a performance gain of about 40% compared to Eigen.
And yes, Eigen also uses the LAPACK test suite to check their results. They do this for 3 functions (Lu, Cholesky and Eigenvalues/-vectors of a symmetric matrix). However, their computation of eigenvalues/-vectors of a non-symmetric matrix would fail the LAPACK test suite.
Disclaimer: Yes, FLENS is my baby! That means I coded about 95% of it and every line of code was worth it.
|show 8 more comments|