[GiNaC-list] 1by1 matrix to scalar
Felipe Bordeu
felipe.bordeu at ec-nantes.fr
Fri Jun 18 15:06:13 CEST 2010
Hello,
I have a little problem, I'm dealing functions made of matrix products.
My question is, how can "force" ginac to convert automatically all the
1by1 matrices to scalars?.
or do I have to do it manually??
Here is a simple example.
void main2(){
ex m1=symbolic_matrix(1, 3, "x");
ex m2=symbolic_matrix(3, 1, "y");
cout << m1 << std::endl;
cout << m2 << std::endl;
ex m3 = (m1*m2).evalm();
cout << m3 << std::endl;
cout << ex_to<matrix>(m3)(0,0)<< std::endl;;
ex m4 = m3-ex_to<matrix>(m3)(0,0);
cout << m4 << std::endl;
};
the output :
[[x0,x1,x2]]
[[y0],[y1],[y2]]
[[y1*x1+y2*x2+y0*x0]]
y1*x1+y2*x2+y0*x0
-y1*x1+[[y1*x1+y2*x2+y0*x0]]-y2*x2-y0*x0
the last line "should" be zero ?--
thanks
Felipe
More information about the GiNaC-list
mailing list