I spent part of the afternoon wrestling with LAPACK integration in a C++ program, using the unofficial Boost bindings. I learned a couple of interesting things. test.C is a file that demonstrates them.

1. You need to create column-major matrices to pass to LAPACK. The subtle part about this is that the matrices are internally stored as column-major (like Fortran) but are *accessed* like row-major matrices (like C). In other words, even when you declare A as column-major, A(3,5) refers to the third row and fifth column of A. This was not obvious to me.

2. The LAPACK routines may modify the matrices that are passed to them. For example, when using gesv(A,B) to solve a system of linear equations, the matrix B is modified to contain the solution values–this is obvious. It is not obvious, at first, that the matrix A is also modified (and I don’t know what useful information it contains).

3. There does not seem to be any binding to the specialized LAPACK solvers for banded and tri-diagonal matrices. I would like to know why, since my matrix is tri-diagonal and it can probably be solved considerable more quickly.

### Like this:

Like Loading...

*Related*