Building block matrices so trace works properly

Hi,
My question is the following.
suppose I have block matrices:

A={{a,0},{0,0}};
B={{b,0},{0,0}};
C={{c,0},{0,0}};

Is there a way to tell Mathematica that a,b and c are some square matrices (say 3 by 3) so that the output of Tr[A.B.C] is something like Tr[a.b.c] instead of just abc?

Thanks in advance,
Diego

Hi Diego,

What do you mean with Tr. The trace of the transpose? Furthermore the variable β€˜C’ is protected in Mathematica, it has a very special purpous. Always try to use small letters. What do you mean with the β€˜,’ do you mean dot-product? Please clarify what you want. The trace (the sum of the diagonal row) can be obtained by using Total[Diagonal].

Hi Sander,

Sorry I wasn’t very careful in writing my question. so let me rephrase it. Yes by β€œTr” I mean the trace and by β€œ.” the dot product. If I write:

mata = {{a, 0}, {0, 0}};
matb = {{b, 0}, {0, 0}};
matc = {{c, 0}, {0, 0}};

And then

Tr[mata.matb.matc]
Tr[matb.mata.matc]

The output is
a b c
a b c
which is fine if a,b and c are numbers. However, if they are matrices, then in general Tr[a.b.c] and Tr[b.a.c] are different. So I would like to keep track of this, without having to define a, b and c.

ArrayFlatten will do the job.

a = RandomInteger[5, {3, 3}];
b = RandomInteger[5, {3, 3}];
f = RandomInteger[5, {3, 3}];

MatrixForm /@ {a, b, f}

2013-11-16_18-39-24.png

A = {{a, 0}, {0, 0}};
B = {{b, 0}, {0, 0}};
F = {{f, 0}, {0, 0}};

MatrixForm[ArrayFlatten[#]] & /@ {A, B, F}

2013-11-16_18-40-25.png

Now check:

In[]:= a.b.f // Tr
Out[]= 809


In[]:= ArrayFlatten[A].ArrayFlatten[B].ArrayFlatten[F] // Tr
Out[]= 809

Also see: How to enter matrices in block matrix format?

Thank you for your help!