Hi guys, 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 ? Thanks, Marco
Hi Marco, On Tue, Jun 28, 2005 at 04:05:46PM -0300, mdias@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: #include <iostream> using namespace std; #include <ginac/ginac.h> using namespace GiNaC; int main() { symbol f1("f1"), f2("f2"); symbol A("A"), B("B"); matrix M(2, 2, lst(f1, f1*f2, 0, 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; return 0; } Just a small example that can easily be adapted to bigger systems. Regards, Jens
Thanks. I will implement this Marco Andre Ferreira Dias On Wed, 29 Jun 2005, Jens Vollinga wrote:
Hi Marco,
On Tue, Jun 28, 2005 at 04:05:46PM -0300, mdias@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:
#include <iostream> using namespace std; #include <ginac/ginac.h> using namespace GiNaC;
int main() { symbol f1("f1"), f2("f2"); symbol A("A"), B("B");
matrix M(2, 2, lst(f1, f1*f2, 0, 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;
return 0; }
Just a small example that can easily be adapted to bigger systems.
Regards, Jens
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de http://thep.physik.uni-mainz.de/mailman/listinfo/ginac-list
On Tue, 28 Jun 2005 mdias@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 ?
Please have a close look at the code in check/exam_lsolve.cpp and check/check_lsolve.cpp. It contains several regression tests for lsolve including over- and underdetermined linear systems. Regards -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
participants (4)
-
Jens Vollinga
-
Marco Andre Ferreira Dias
-
mdias@ift.unesp.br
-
Richard B. Kreckel