Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-03-02 07:16:14


On Friday 02 March 2007 12:17, Sourabh wrote:
> The following program aborts when I am trying to use assign.
> What is the proper way of dealing with matrices of size 1e7, which are
> sparse and lower triangular.

see below.

> The question I have is, how costly is it to
> take inverse of such matrices ?

Don't do this. The inverse of a sparse matrix is usually dense, the
computation time grows like n^3 (or even worse) and the error can be as large
as n^2 * 1.0e-14 ... I order to solve sparse linear systems you can either
use a direct method (provided by UMFPACK or CXSparse) or an iterative method
(provided by my examples or the Iterative Template Library). Solver for
triangular systems are also available.

(Or wait a few days/weeks until my native ublas sparse LU decomposition is
finished.)

> I also have to do multiplication and
> addition of such matrices.

multiplication is done by sparse_prod (operation_sparse.hpp) or simply by
prod(). Addition uses operator + () or operator += ().

> The improper way, as mentioned in the program
> below causes abortion of program.
> The exact assertion used was :
>
> boost/numeric/ublas/functional.hpp at line 1406:
> size2 == 0 || i <= ((std::numeric_limits<size_type>::max) () - j) / size2
> Aborted (core dumped)

mapped_matrix has the size limit
(size1*size2) < std::numeric_limits<size_type>::max

try compressed_matrix and have a look at the list archives at [2]

mfg
Gunter

[1] http://www.bauv.unibw-muenchen.de/~winkler/ublas/examples/
[2] http://dir.gmane.org/gmane.comp.lib.boost.ublas