Discussion:
Stop mathematica reordering expression during matrix multiply
(too old to reply)
Robert Wright
2010-04-24 07:59:15 UTC
Permalink
I am using a Graph Theory algorithm which requires that I multiply an edge-weighted adjacency matrix with symbolic parts. In my problem, the order of the symbols corresponds to the edges that make up a path - for example, x2 x1 x7 would indicate that the path progresses from x2 to x1 then x7. The snag comes when Mathematica reorders the symbols in each expression appearing in the matrix result from multiplying Ci x Cj - is there a way of stopping this from happening?

Here is some code that illustrates the problem:

C1 = {{0, x1, 0, 0}, {x2, 0, x3, 0}, {x4, 0, 0, x5}, {x6, 0, x7, 0}};
C2 = C1.C1;
***@C2

The MatrixForm output shows how Mathematica has sequenced the symbols in 'ascending' order. In my case, I want to preserve the order of the symbols in the calculated expression: so, for example, row 4 of C1 times column 2 of C1 should give x4 x1 and not x1 x4. How do I stop Mathematicafrom reordering the resulting expression?
Simon
2010-04-25 10:26:17 UTC
Permalink
Hi Robert,

I think that what you want to do can be found on the research page of
George Stacey Staples:
http://www.siue.edu/~sstaple/index_files/research.htm

Simon
I am using a Graph Theory algorithm which requires that I multiply an edg=
e-weighted adjacency matrix with symbolic parts. In my problem, the order o=
f the symbols corresponds to the edges that make up a path - for example, x=
2 x1 x7 would indicate that the path progresses from x2 to x1 then x7. The =
snag comes when Mathematica reorders the symbols in each expression appeari=
ng in the matrix result from multiplying Ci x Cj - is there a way of stoppi=
ng this from happening?
C1 = {{0, x1, 0, 0}, {x2, 0, x3, 0}, {x4, 0, 0, x5}, {x6, 0, x7, 0}};
C2 = C1.C1;
The MatrixForm output shows how Mathematica has sequenced the symbols in =
'ascending' order. In my case, I want to preserve the order of the symbols =
in the calculated expression: so, for example, row 4 of C1 times column 2 o=
f C1 should give x4 x1 and not x1 x4. How do I stop Mathematicafrom reorder=
ing the resulting expression?

Loading...