0
|
4701 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
GROUPS:

# Building block matrices so trace works properly

Posted 11 years ago
 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
4 Replies
Sort By:
Posted 11 years ago
 ArrayFlatten will do the job.a = RandomInteger[5, {3, 3}];b = RandomInteger[5, {3, 3}];f = RandomInteger[5, {3, 3}];MatrixForm /@ {a, b, f}A = {{a, 0}, {0, 0}};B = {{b, 0}, {0, 0}};F = {{f, 0}, {0, 0}};MatrixForm[ArrayFlatten[#]] & /@ {A, B, F}Now check:In[]:= a.b.f // TrOut[]= 809In[]:= ArrayFlatten[A].ArrayFlatten[B].ArrayFlatten[F] // TrOut[]= 809Also see: How to enter matrices in block matrix format?
Posted 11 years ago
Posted 11 years ago
 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 thenTr[mata.matb.matc]Tr[matb.mata.matc]The output is a b ca b cwhich 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.
Posted 11 years ago
 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].
Community posts can be styled and formatted using the Markdown syntax.