Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-02-22 08:00:33


On Wednesday 22 February 2006 07:53, asaf david wrote:
> say i got a non triangular matrix M and a vector b, and i'd like to find
> the vector x such that Mx=b. is there any way to perform this ? because
> appearently there's only solver for triangular matrixes. btw i'm sorry if
> it has been answered before, i coudlnt find a search option in the archives

you should use the LU-factorization. The code is like this:

// possibly some more ublas includes here
#include <boost/numeric/ublas/lu.hpp>
matrix<double> A(n,n);
vector<double> b(n);
vector<double> x(n);
permutation_matrix P(n);

lu_factorize(A,P);
x = b;
lu_substitute(A,P,x);

the x ist the solution of Ax=b.

mfg
Gunter