[GiNaC-list] (no subject) has to be: avoid expansion in matrix operations

Sheplyakov Alexei varg at theor.jinr.ru
Wed Mar 8 19:53:16 CET 2006


Hello!

On Tue, Mar 07, 2006 at 07:49:21PM +0100, Javier Ros Ganuza wrote:
> 
> I found that performing programing the matrix  product myself I get the
> desired result (Sum_k A(i,k)*B(k,i)). But is there a more elegant way?
> 
> Javier Ros
> 
> On Tue, 2006-03-07 at 19:31 +0100, Javier Ros Ganuza wrote:
> > Hello! :)
> > 
> > When performing matrix multiplications expressions get expanded like in
> > the following Example.
> > 
> > Is there a way to avoid expansion, that is to leave the parenthesis

You can try this silly patch:

Index: ginac/matrix.cpp
===================================================================
RCS file: /home/cvs/GiNaC/ginac/matrix.cpp,v
retrieving revision 1.99.2.5
diff -u -r1.99.2.5 matrix.cpp
--- ginac/matrix.cpp	19 Oct 2005 21:21:56 -0000	1.99.2.5
+++ ginac/matrix.cpp	8 Mar 2006 18:51:06 -0000
@@ -583,7 +583,7 @@
 			if (m[r1*col+c].is_zero())
 				continue;
 			for (unsigned r2=0; r2<other.cols(); ++r2)
-				prod[r1*other.col+r2] += (m[r1*col+c] * other.m[c*other.col+r2]).expand();
+				prod[r1*other.col+r2] += (m[r1*col+c] * other.m[c*other.col+r2]);
 		}
 	}
 	return matrix(row, other.col, prod);


Best regards,
  Alexei.

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20060308/f41fac8f/attachment.pgp


More information about the GiNaC-list mailing list