[GiNaC-list] GiNaC::marix::solve(..)

Lisa Maletzki l.maletzki at tu-bs.de
Wed Jun 3 13:17:59 CEST 2009


> Message: 1
> Date: Tue, 02 Jun 2009 18:37:08 +0200
> From: Lisa Maletzki <l.maletzki at tu-bs.de>
> Subject: [GiNaC-list] GiNaC::marix::solve(..) problem
> To: ginac-list at ginac.de
> Message-ID: <20090602183708.y2zyinropw4o840k at webmail.tu-bs.de>
> Content-Type: text/plain;	charset=ISO-8859-1;	DelSp="Yes";
> 	format="flowed"
>
> Hey,
>
> I have a smallish problem with the method mentioned above
> (matrix::solve(..)). I have two nxn numeric matrices A and b (from the
> equation Ax=b) and of course want the matrix x in the end but I keep
> on getting the error that the first argument must be a matrix of
> symbols. Now my question how can I do that? I tried it with ex
> symbolic_matrix(..) but I couldn't get it to work since it is of the
> type ex and not matrix.
>
> Kind regards,
>
> Lisa
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 02 Jun 2009 19:35:08 +0200
> From: Jens Vollinga <jensv at nikhef.nl>
> Subject: Re: [GiNaC-list] GiNaC::marix::solve(..) problem
> To: GiNaC discussion list <ginac-list at ginac.de>
> Message-ID: <4A2562CC.2020405 at nikhef.nl>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi,
>
> Lisa Maletzki schrieb:
>> I have a smallish problem with the method mentioned above
>> (matrix::solve(..)). I have two nxn numeric matrices A and b (from the
>> equation Ax=b) and of course want the matrix x in the end but I keep on
>> getting the error that the first argument must be a matrix of symbols.
>> Now my question how can I do that? I tried it with ex
>> symbolic_matrix(..) but I couldn't get it to work since it is of the
>> type ex and not matrix.
>
> take the following example as a guide:
>
> 	matrix A(2,2);
> 	A = 1, 2, 3, 4;
> 	symbol x1("x1"), x2("x2");
> 	matrix x(2,1);
> 	x = x1, x2;
> 	matrix b(2,1);
> 	b = 5, 6;
> 	cout << A.solve(x, b) << endl;
>
> As the manual warns, you will get an exception thrown if the system is
> overdetermined. A more robust version is shown in the following example
> using no matrices:
>
> 	symbol x1("x1"), x2("x2");
> 	lst equations;
> 	equations.append(1*x1 + 2*x2 == 5);
> 	equations.append(3*x1 + 4*x2 == 6);
> 	cout <<  lsolve(equations, lst(x1,x2)) << endl;
>
> Regards,
> Jens
>

Thank you Jens. But the problem I have is, that I do not know how big  
my matrix will be. In the smallest case it is a 18x18 matrix, so  
getting all those symbols would be rather complicated, or am I just  
thinking that?

Kind regards,

Lisa



More information about the GiNaC-list mailing list