While ago, when I started doing some linear algebra in C
, it came to me as a surprise to see there are so few tutorials for BLAS
, LAPACK
and other fundamental API
s, despite the fact that they are somehow the cornerstones of many other libraries. For that reason I started collecting all the examples/tutorials I could find all over the internet for BLAS
, CBLAS
, LAPACK
, CLAPACK
, LAPACKE
, ATLAS
, OpenBLAS
... in this Github repo.
Well, I should warn you that as a mechanical engineer I have little experience in managing such a git repository or GitHub. It will first seem as a complete mess to you guys. However if you manage to get over the messy structure you will find all kind of examples and instructions which might be a help. I have tried most of them, to be sure they compile. And the ones which do not compile I have mentioned. I have modified many of them to be compilable with GNU compilers
(gcc
, g++
and gfortran
). I have made MakeFile
s which you can read to learn how you can call individual Fortran/FORTRAN
routines in a C
or C++
program. I have also put some installations instructions for mac and linux (sorry windows guys!). I have also made some bash
.sh
files for automatic compilation of some of these libraries.
But going to your other question: BLAS
and LAPACK
are rather API
s not specific SDK
s. They are just a list of specifications or language extensions rather than an implementations or libraries. With that said, there are original implementations by Netlib in FORTRAN 77
, which most people refer to (confusingly!) when talking about BLAS
and LAPACK
. So if you see a lot of strange things when using these API
s is because you were actually calling FORTRAN
routines in C
rather than C
libraries and functions. ATLAS
and OpenBLAS
are some of the best implementations of BLAS
and LACPACK
as far as I know. They conform to the original API
, even though, to my knowledge they are implemented on C/C++
from scratch (not sure!). There are GPGPU implementations of the API
s using OpenCL
: CLBlast, clBLAS, clMAGMA, ArrayFire and ViennaCL to mention some. There are also vendor specific implementations optimized for specific hardware or platform, which I strongly discourage anybody to use them.
My recommendation to anyone who wants to learn using BLAS
and LAPACK
in C
is to learn FORTRAN-C
mixed programming first. The first chapter of the mentioned repo is dedicated to this matter and there I have collected many different examples.
P.S. I have been working on the dev branch of the repository time to time. It seems slightly less messy!