[GiNaC-list] matrix::solve(): how to use?
vollinga at thep.physik.uni-mainz.de
Wed Jun 29 16:47:19 CEST 2005
On Tue, Jun 28, 2005 at 04:05:46PM -0300, mdias at ift.unesp.br wrote:
> I am tryng to solve a linear system with lsove(), with many variables
> being zero, so lsolve() tell that is indeterminate, but some of these
> entries are of interest.
> So, I am looking for matrix::solve and construct a matrix to solve this.
> Somebody have a piece of code how to make a linear system a matrix to
> matrix::solve ?
I don't completely understand your question concerning these "entries of
interest", but maybe you want to have something like this:
using namespace std;
using namespace GiNaC;
symbol f1("f1"), f2("f2");
symbol A("A"), B("B");
matrix M(2, 2, lst(f1, f1*f2,
matrix x(2, 1, lst(A, B));
matrix b(2, 1, lst(5, 10));
// M x = b
matrix result = M.solve(x, b);
cout << result << endl;
Just a small example that can easily be adapted to bigger systems.
More information about the GiNaC-list