Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-10-27 15:47:22

On Oct 27, 2004, at 2:39 PM, Bronek Kozicki wrote:

> I know that question is little off-topic here, but I hope there is
> someone who can answer it. Could you recommend some C++ library for
> matrix calculation that supports matrix inversion? Blizt++ does not
> have it, neither boost.ublas. Or I missed it. Ideas?

It's been a few years since I was doing linear algebra (omg, nearly a
decade!), and I'm not familiar with the interface of Blitz++ or
boost.ublas, but if the library supports direct factorization of a
matrix, I believe you can compute the inverse very efficiently with
something like:

vector f = {0};
for (unsigned i = 0; i < ncols; ++i)
     f[i] = 1;
     solve(matrix, inverse.col(i), f);
     f[i] = 0;

I.e. you can generate a column of the inverse at a time by solving
against a vector with all zero's except for a 1 in the column/row of
interest. Indeed, it is because of this relationship that it may not
be necessary at all to ever store the entire inverse. The factored
original is just as good.


Boost list run by bdawes at, gregod at, cpdaniel at, john at