[Date Index]
[Thread Index]
[Author Index]
Re: Stop mathematica reordering expression during matrix
*To*: mathgroup at smc.vnet.net
*Subject*: [mg109410] Re: Stop mathematica reordering expression during matrix
*From*: Bob Hanlon <hanlonr at cox.net>
*Date*: Sun, 25 Apr 2010 06:26:41 -0400 (EDT)
mult[x_?MatrixQ, y_?MatrixQ] :=
Inner[NonCommutativeMultiply, x, y] /.
{_ ** 0 -> 0, 0 ** _ -> 0}
c1 = {{0, x1, 0, 0}, {x2, 0, x3, 0},
{x4, 0, 0, x5}, {x6, 0, x7, 0}};
c2 = mult[c1, c1]
{{x1 ** x2, 0, x1 ** x3, 0},
{x3 ** x4, x2 ** x1, 0, x3 ** x5},
{x5 ** x6, x4 ** x1, x5 ** x7, 0},
{x7 ** x4, x6 ** x1, 0, x7 ** x5}}
Bob Hanlon
---- Robert Wright <mathematicauser1 at yahoo.com> wrote:
=============
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;
MatrixForm@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?
Prev by Date:
**Re: Function to detect presence of a variable in**
Next by Date:
**Re: Function to detect presence of a variable in**
Previous by thread:
**Re: Function to detect presence of a variable in**
Next by thread:
**Re: Stop mathematica reordering expression during matrix**
| |